PROBLEM 45: Prime
Program to find out all the prime numbers from the range of 0 to n.
Name - Ajay Zad
Date - 14/03/2022
n = int(input("Enter the value for n :"))
cnt = 0
print("The Prime numbers are :")
for i in range(2,n+1):
for j in range(2,i):
if i % j == 0:
cnt = cnt + 1
if cnt == 0:
print(i)
cnt = 0
Input:
Enter the value for n :
10
Output :
The Prime numbers are :
2
3
5
7
No comments:
Post a Comment