Write a Python Program to Check Prime Number?

Updated: Feb 25


Write Python Program to Check input number is Prime Number? Program: num = int(input("Enter any number: "))

if num > 1:

for i in range(2, num):

if num % i == 0:

print("The number is not prime",num)

break

else:

print("The number is prime",num)


Output:

Enter any number: 5 The number is prime 5

Write a python program to print all the prime numbers between 1 to 100.

Program:

for i in range (2,100):

for j in range (2,i):

if i%j==0:

break

else:

print(i)

Output:

2

3

5

7

11

:

:

97



23 views0 comments

Recent Posts

See All
 

9555593818

Thakurdwara, Uttar Pradesh 244601, India

  • Facebook
  • Twitter
  • LinkedIn