OFFSET
0,7
FORMULA
Sides a,b,c must satisfy the conditions that (1) a^2 + b^2 + c^2 = d^2 and (2) a, b, and c are positive, coprime, and not > n.
EXAMPLE
n=8: [1,2,2],[1,4,8],[2,3,6],[4,4,7],[6,6,7].
PROG
(Python)
def coprime(k, m, n):
while m:
k, m=m, k%m
if k==1:return 1
while k:
n, k=k, n%k
return n
def a(n):
kv=set(i**2 for i in range(2*n))
pyt=0
for a in range(1, n):
for b in range(a, n+1):
for c in range(b, n+1):
if a**2+b**2+c**2 in kv and coprime(a, b, c)==1:
pyt+=1
return pyt
print([a(n) for n in range(70)])
CROSSREFS
KEYWORD
nonn
AUTHOR
Knut Ångström, Nov 27 2016
EXTENSIONS
Formula clarified by Harvey P. Dale, Dec 08 2017
STATUS
approved
