Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def is_prime(n):
- if n <= 1:
- return False
- for i in range(2, int(math.sqrt(n)) + 1):
- if n % i == 0:
- return False
- return True
- num = int(input("Enter a number: "))
- if is_prime(num):
- print(num, "is a prime number.")
- else:
- print(num, "is not a prime number.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement