Skip to content

Instantly share code, notes, and snippets.

@chrisy
Created April 18, 2016 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisy/0e77f8464a30638618cdae8fcf943a5e to your computer and use it in GitHub Desktop.
Save chrisy/0e77f8464a30638618cdae8fcf943a5e to your computer and use it in GitHub Desktop.
def defined_range(user_input):
if 1 <= user_input <= 10000:
return True
else:
return False
print "Please give me a number between 1 and 10000 to find if it is prime "
while True:
user_input = int(raw_input('Please input your number '))
if defined_range(user_input) == True:
div = user_input - 1
result = True
while(div > 1):
if user_input % div == 0:
print "This number is divisible by " + str(div)
result = False
div = div - 1
if result == False:
print "This is not prime"
if result == True:
print "This is a prime"
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment