title: What is the time complexity of the algorithm to check if a number is prime?
body: <p>I need to find what is the time complexity of an algorithm that checks if an integer is prime? This algorithm  is a bit different in that it uses a while loop to accomplish its task</p>
  
  <p>Here's the method in Java:</p>
  
  <pre><code>    public static boolean isPrime(int num) {
          int i = 2;
          boolean isPrime = false;
  
          while(num % i != 0) {
              i += 1;
          }
  
          if (num == i) {
              isPrime = true;
          }
  
          return isPrime;
      }
  </code></pre>
  
  <p>For the while loop, I have one comparison and I have one if statement outside the loop, the if statement will always be ran once so O(1). Now what is big-O of the while loop? Is it O(n)?</p>