Skip to content

Commit b3c3c73

Browse files
mysterious Primes
1 parent 9d4e26d commit b3c3c73

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

PRIME.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# displaying prime numbers
2+
def isprime(x):
3+
p=0
4+
for n in range (2,x):
5+
if x%n==0:
6+
p +=1
7+
if p>=1:
8+
return False
9+
else:
10+
return True
11+
12+
n=int(input("how many primes you want to print?\n-->"))
13+
primesList=[]
14+
f=2
15+
primes=0
16+
while primes!=n:
17+
for x in range (f,f*2):
18+
if isprime(x):
19+
primes +=1
20+
primesList.append(x)
21+
if primes == n:
22+
break
23+
f *=2
24+
for i in primesList:
25+
print(i)

0 commit comments

Comments
 (0)