title: state difference in time complexities?
body: <pre><code>int prime(ll n)
  {
      for(int i=2;i&lt;=sqrt(n);i++){
          if(n%2==0){
              return 0;
          }
      }
      return 1;
  }
  
  
  int prime(ll n)
  {
      if(n&lt;2)
          return 0;
      else if(n==2)
          return 1;
      if(n%2==0)
          return 0;
      for(int j=3; j*j&lt;=n; j+=2)
      {
          if(n%j==0)
              return 0;
      }
      return 1;
  }
  </code></pre>
  
  <p>can anyone please tell me the difference between the time complexities of these functions? 
  Because using the above function in my code, it gives me wrong answer in codeforces round #142 Div 2 problem. But choosing the second function gives me correct answer. Why ??</p>