title: why < is much faster than !=?
body: <blockquote>
    <p>Problem : Consider the following algorithm to generate a sequence of
    numbers. Start with an integer n. If n is even, divide by 2. If n is
    odd, multiply by 3 and add 1. Repeat this process with the new value
    of n, terminating when n = 1. The input will consist of a series of
    pairs of integers i and j, one pair of integers perline. All integers
    will be less than 1,000,000 and greater than 0. 
    For each pair of
    input integers i and j, output i, j in the same order in which they
    appeared in the input and then the maximum cycle length for integers
    between and including i and j. These three numbers should be separated
    by one space, with all three numbers on one line and with one line of
    output for each line of input.</p>
  </blockquote>
  
  <p>sample input :</p>
  
  <pre><code>1 10
  </code></pre>
  
  <p>sample output:</p>
  
  <pre><code>1 10 20
  </code></pre>
  
  <p>so i wrote this : </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  struct line{int in1;int in2;int result;};
  
  int cycle(int in);
  
  int main(int argc, char *argv[]) {
      int cycle(int in);
      char c;
      int firstIn=0;
      struct line l[500] ;
      int pointer=0;
  
      while(2&lt;3){
          l[pointer].in1=0;
          l[pointer].in2=0;
          scanf("%u %u",&amp;l[pointer].in1,&amp;l[pointer].in2);
          if(l[pointer].in1&lt;1||l[pointer].in2&lt;1){
              break;
          }
  
          int maxCyc=0;
          int j,m;
          int min,max;
          if(l[pointer].in1&gt;l[pointer].in2){
              max=l[pointer].in1;
              min=l[pointer].in2;
          }
          else{
              max=l[pointer].in2;
              min=l[pointer].in1;
          }
          for(j=min;j&lt;=max;j++){
  
              m = cycle(j);
              if(m&gt;maxCyc)
                  maxCyc=m;
          }
          l[pointer].result=maxCyc;
          printf("%d %d %d\n",l[pointer].in1,l[pointer].in2,l[pointer].result);
          pointer++;
      }
  }
  
  int cycle(int in){
      int cyc = 1;
      while(in&gt;1){
          if(in%2==0){
              cyc++;
              in=in/2;
          }
          else{
              cyc++;
              in=in*3+1;
          }
      }
      return cyc;
  }
  </code></pre>
  
  <p>Its completly ok but when you change <code>while(in&gt;1)</code> in cycle method to <code>while(in!=1)</code> it gets much more slower. my question is why?!</p>
  
  <blockquote>
    <p>Time when its <code>while(in&gt;1)</code> : 0.683 sec</p>
    
    <p>and when its <code>while(in!=1)</code> : I waited more than 5 min nothing
    happened yet :)</p>
    
    <p>for input : 1 1000000</p>
  </blockquote>
  
  <p>there is no infinite loop or something because <code>in</code> cant get below 1 at all(for that it must be already 1) .</p>
  
  <p>Best regards</p>