Created
November 12, 2018 13:22
-
-
Save telliott99/b543f41d84155bc9171df68b6350e256 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# greatest common divisor | |
from fractions import gcd | |
n = 100 | |
# pre-compute squares | |
N = 15*n | |
L = [False] | |
L.extend([i**2 for i in range(1,N)]) | |
rL = list() | |
for i in range(3,n+1): | |
for j in range(i+1,N): | |
if gcd(i,j) != 1: | |
continue | |
c_sq = L[i] + L[j] | |
if c_sq in L: | |
rL.append((i,j,L.index(c_sq))) | |
rL.sort() | |
for t in rL: | |
a,b,c = t | |
s = '%4d ' * 3 | |
print s % (a,b,c) | |
''' | |
> python triples.py > triples.txt | |
> cat triples.txt | |
3 4 5 | |
5 12 13 | |
7 24 25 | |
8 15 17 | |
9 40 41 | |
11 60 61 | |
12 35 37 | |
13 84 85 | |
15 112 113 | |
16 63 65 | |
17 144 145 | |
19 180 181 | |
20 21 29 | |
20 99 101 | |
21 220 221 | |
23 264 265 | |
24 143 145 | |
25 312 313 | |
27 364 365 | |
28 45 53 | |
28 195 197 | |
29 420 421 | |
31 480 481 | |
32 255 257 | |
33 56 65 | |
33 544 545 | |
35 612 613 | |
36 77 85 | |
36 323 325 | |
37 684 685 | |
39 80 89 | |
39 760 761 | |
40 399 401 | |
41 840 841 | |
43 924 925 | |
44 117 125 | |
44 483 485 | |
45 1012 1013 | |
47 1104 1105 | |
48 55 73 | |
48 575 577 | |
49 1200 1201 | |
51 140 149 | |
51 1300 1301 | |
52 165 173 | |
52 675 677 | |
53 1404 1405 | |
56 783 785 | |
57 176 185 | |
60 91 109 | |
60 221 229 | |
60 899 901 | |
64 1023 1025 | |
65 72 97 | |
68 285 293 | |
68 1155 1157 | |
69 260 269 | |
72 1295 1297 | |
75 308 317 | |
76 357 365 | |
76 1443 1445 | |
84 187 205 | |
84 437 445 | |
85 132 157 | |
87 416 425 | |
88 105 137 | |
92 525 533 | |
93 476 485 | |
95 168 193 | |
96 247 265 | |
100 621 629 | |
> | |
''' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment