Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. def check_number():
  2. 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
  3.  
  4. give1 = int(give/2) # we know a number greater than the half of that number won't be able to divide it
  5. # COnveriting into integer because the result will be float
  6.  
  7. for i in range(1,give1):
  8. if give % i == 0:
  9. print('THe number {} is prime'.format(give))
  10. break # since there is now no pint in continuing the if loop
  11. else:
  12. print('The number {} is not prime {}'.format(give))
  13.  
  14.  
  15. check_number()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement