-
Notifications
You must be signed in to change notification settings - Fork 0
/
primecrawler.py
42 lines (40 loc) · 1004 Bytes
/
primecrawler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#Made by C272. http://c272.ga
foundPrime = 0
#Prime array.
while True:
try:
file = open("primes.txt", "r")
except FileNotFoundError:
file = open("primes.txt", "w")
file.write("2"+"\n")
file.flush()
primes = ["2"]
break
else:
primesUnformat = file.readlines()
primes = []
for i in primesUnformat:
primes.append(i.replace("\n", ""))
file.close()
break
#Starting number.
x = 3
while True:
isPrime = 1
for i in primes:
if int(i)<int(x):
if x%int(i)==0:
isPrime = 0
if isPrime==0:
arbit = "true"
else:
print(str(x)+" is prime.")
foundPrime=1
if str(x) not in primes:
file = open("primes.txt", "a")
file.write(str(x)+"\n")
file.close()
if str(x) not in primes:
primes.append(str(x))
#Next number.
x+=1