Title: List of Prime numbers up to given number
Program:
n=int(input("Enter n value\n"))
for i in range(2,n+1):
c=0
for j in range(1,i+1):
if(i%j==0):
c=c+1
if(c==2):
print(i)
Output:
Enter n value
30
2
3
5
7
11
13
17
19
23
29
Comments
Post a Comment