Change your code to reflect that, you have to tell it when your number is equal to 3 it is a prime!
Here is a code sample I created and here is the theory behind it, it can theroicaly find primes up to 10,000,000,000
Here is a link to a post on codeacademy.
This function computes all the whole numbers from 3 to the square root of the
number + 1, this takes out a bunch of un-need computations.
:param number: Number to be computed
:return: Returns True if is prime Else False
if number > 1:
# This line checks if the number is greater than one, if not returns False
if number == 2:
# This line checks to see if the number is 2, if so Returns True
if number % 2 == 0:
# This line checks to see of the number is divisible by two if so Returns False
for current in range(3, int(sqrt(number) + 1), 2):
# This line iterates through the range of numbers from 3 to the square root of
# the number + 1 with a stride of two
# So numbers would be non-even numbers
if number % current == 0:
# If a number divides into our number Returns False
# Returns True if non of the previous tests failed