Advertisement
immanual1

prime

Jan 13th, 2025
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. import math
  2.  
  3. def is_prime(n):
  4.  
  5.  
  6. if n <= 1:
  7. return False
  8.  
  9. for i in range(2, int(math.sqrt(n)) + 1):
  10. if n % i == 0:
  11. return False
  12.  
  13. return True
  14.  
  15.  
  16. num = int(input("Enter a number: "))
  17.  
  18. if is_prime(num):
  19. print(num, "is a prime number.")
  20. else:
  21. print(num, "is not a prime number.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement