Python Program to check whether a number is prime or not.

num = 15

count = 0

for i in range(2,num):

if num%i==0:

count = 1

break

if count == 1:

print(‘Not Prime’)

else:

print(“Prime”)

1 Like

num =int(input())

flag=0

for i in range (2, num):

if (num % i) == 0:

flag += 1

print(“Not prime”)

break

if flag== 0:

print(“prime number”)

1 Like

numr=int(input(“Enter range:”))

print(“Prime numbers:”,end=’ ')

for n in range(1,numr):

```
for i in range(2,n):
if(n%i==0):
break
else:
print(n,end=' ')
```

1 Like

num = 11

num = int(input("Enter a number: "))

if num == 1:

print(num, “is not a prime number”)

elif num > 1:

```
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
break
```

else:

print(num,“is a prime number”)

print(num,“is not a prime number”)

1 Like