Prime Number:
Any number divisible by 1 and itself that number is called prime number.
Example:
num = int(input("enter number: "))
if num > 1:
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
print(i,"times",num//i,"is",num)
break
else:
print(num,"is a prime number")
else:
print(num,"is not a prime number")
Output:
enter number: 5
5 is a prime number
Output:
enter number: 12
12 is not a prime number
2 times 6 is 12
Output:
enter number: 15
15 is not a prime number
3 times 5 is 15
No comments:
Post a Comment