title: Python and the modulus operator with very large numbers
body: <p>I apologize in advance if this is a duplicate question - my search for <code>python</code> and <code>modulus</code> ran up to 8 pages of questions and that combined with my relatively little coding experience made it somewhat difficult for me to check thoroughly to see if there was anything extremely similar out there.</p>
  
  <p>While trying to solve a <a href="https://projecteuler.net" rel="nofollow">Project Euler</a> question, I wrote a function for testing whether or not a number was a prime number:</p>
  
  <pre><code>import math
  def isprime(n):
      if n % 1 != 0:
          return(False)
      else:
          for j in range(2, math.ceil(math.sqrt(n)) + 1):
              if n % j == 0:
                  return(False)
              else:
                  return(True)
          break
  </code></pre>
  
  <p>This works pretty well with small numbers, but with very large numbers that definitely <em>aren't</em> prime (e.g. I put in <code>isprime(1012321312412431434334545555)</code> and the function gives me a value of <code>True</code>). Why is this the case?</p>
  
  <p>EDIT: as pointed out by roippi and confirmed by my further investigations, this function actually does not work for a lot of smaller odd composite numbers. I'm trying to figure out why that doesn't work for now.</p>