-
Notifications
You must be signed in to change notification settings - Fork 0
/
p75.py
36 lines (28 loc) · 798 Bytes
/
p75.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
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 27 23:01:04 2017
@author: Refaia
"""
import time
import math
def main() :
limitP = 15*(10**5)
delta = time.time()
a, b, c = 0, 0, 0
m = 2
ways = [0 for i in range(limitP + 1)]
for m in range(2, math.floor(math.sqrt(limitP)) + 1):
for n in range(1, m) :
if (math.gcd(n, m) == 1) and (n % 2 == 0 or m % 2 == 0) :
a = (m * m - n * n)
b = (2 * m * n)
c = (m * m + n * n)
if a + b + c > limitP :
break
s = sum((a, b, c))
for i in range(s, len(ways), s) :
ways[i] += 1
result = ways.count(1)
delta = time.time() - delta
return result, delta
print(main())