Prime Number Program in Python
Prime number in C: Prime number is a number that is greater than 1 and divided by 1 or itself. In other words, prime numbers can't be divided by other numbers than itself or 1. For example 2, 3, 5, 7, 11, 13, 17, 19, 23.... are the prime numbers.
Program:
m=0;flag=0;
n=int(input("Enter the number to check prime:"));
m=n//2;
for i in range(2,m+1,1):
if(n%i==0):
print("Number is not prime");
flag=1;
break;
if(flag==0):
print("Number is prime");
OutPut:
No comments:
Post a Comment