Skip to content

Instantly share code, notes, and snippets.

@Nishan8583
Created July 24, 2016 06:44
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 Nishan8583/808dced6e29e18c60f4f4a5d5883ac5d to your computer and use it in GitHub Desktop.
Save Nishan8583/808dced6e29e18c60f4f4a5d5883ac5d to your computer and use it in GitHub Desktop.
def check_number():
give = int(input('Enter the number you want to check is prime or not : ')) # asking input andconverting it into integer since by default it will be string
give1 = int(give/2) # we know a number greater than the half of that number won't be able to divide it
# COnveriting into integer because the result will be float
for i in range(1,give1):
if give % i == 0:
print('THe number {} is prime'.format(give))
break # since there is now no pint in continuing the if loop
else:
print('The number {} is not prime {}'.format(give))
check_number()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment