-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem46.py
More file actions
41 lines (29 loc) · 985 Bytes
/
problem46.py
File metadata and controls
41 lines (29 loc) · 985 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import time
import math
from mymodule import calculate_time
from mymodule import is_prime
from mymodule import is_square_number
#########################################################################3
#########################################################################3
@calculate_time
def main():
index = 9
primes = {2, 3, 5, 7}
while True:
if is_prime(index):
primes |= {index}
else:
count = len(primes)
for e in primes:
if (index - e)%2 == 0 and is_square_number((index-e)/2):
print("{}={} + 2x{}^2".format(index, e, int(math.sqrt((index -e)/2))))
break
else:
count -= 1
if count == 0:
print("Found: {}".format(index))
break
index += 2
return 0
if __name__ == "__main__":
main()