-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem622b.py
More file actions
27 lines (25 loc) · 764 Bytes
/
problem622b.py
File metadata and controls
27 lines (25 loc) · 764 Bytes
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
upper = 60
number = 2 ** upper
file = open("candidates.txt", "r")
candidates = file.readlines()[0].split(" ")
candidates = [int(candidates[i]) for i in range(len(candidates)-1)]
file.close()
print(len(candidates))
endIndex = len(candidates)
lowerBound = candidates[-1]
upperBound = lowerBound * 10
for i in range(lowerBound, 1152921504606846976, 2):
if number % (i-1) == 1:
addTo = True
for j in range(1, upper):
newNumber = 2 ** j
if newNumber % (i-1) == 1:
addTo = False
break
if addTo:
candidates.append(i)
print(len(candidates))
file = open("candidates.txt", "a")
for i in range(endIndex, len(candidates)):
file.append(str(candidates[i] + " "))
file.close()