top of page
Subham Das

Prime Number or Not

This program checks a number is mathematically prime or not. It is a optimize program to check a number is prime number or not.



# Program to check a number is prime or not.

n = eval(input("Enter Number:"))

flag = 0

if n ==2 :

flag = 1

elif n > 2 :

i = 2

while i > n :

if n%i == 0 :

flag = 1

break

else :

flag = 0

i += 1

else :

flag = 0

if flag == 0 :

print(n,"is a prime number.")

else :

print(n,"is not a prime number.")



9 views0 comments

Recent Posts

See All

Magic Number

It is a composite number whose sum of the digits is 10. If we extract the digits from the number then the sum of these digits will be 10....

Comments


logo12.PNG
bottom of page