title: Checking number is prime in python, why check up to int(sqrt(n)-1)) not int(sqrt(n))
body: <p>new to Python here. I am trying to understand how this function works to check prime numbers:</p>
  
  <pre><code>from itertools import count, islice
  from math import sqrt
  def is_prime(n):
      if n &lt; 2: return False
      return all(n%i for i in islice(count(2), int(sqrt(n)-1)))
  </code></pre>
  
  <p>From what I understand you can check factors up to and <strong>including</strong> the square root of n, so why is this only testing up to sqrt(n)-1? I'm also not clear on the <code>return all</code> part for the function. n%i returns an int, the remainder. So why does this expression evaluate as a bool? Any pointers on this would be great. thanks!</p>