%I #13 Mar 14 2021 14:26:18
%S 0,0,1,1,1,1,2,4,5,6,6,7,10,10,11,12,15,16,19,20,23,25,28,30,33,35,38,
%T 40,44,47,52,54,57,59,63,65,71,73,79,81,86,89,98,101,106,108,114,117,
%U 126,130,137,142,147,150,159,162,173,178,182
%N a(n) is the number of parallelepipeds with vertices with integer coordinates between 0 and n and diagonals from one corner to the opposite corner with an integer length.
%F 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.
%e n=8: [1,2,2],[1,4,8],[2,3,6],[4,4,7],[6,6,7].
%o (Python)
%o def coprime(k,m,n):
%o while m:
%o k,m=m,k%m
%o if k==1:return 1
%o while k:
%o n,k=k,n%k
%o return n
%o oeis=[0]
%o for n in range(n):
%o kv=[i**2 for i in range(2*n)]
%o pyt=[]
%o for a in range(1,n):
%o for b in range(a,n+1):
%o for c in range(b,n+1):
%o if a**2+b**2+c**2 in kv and coprime(a,b,c)==1:
%o pyt.append([a,b,c,int((a**2+b**2+c**2)**0.5+0.1)])
%o oeis.append(len(pyt))
%o print(pyt)
%K nonn
%O 0,7
%A _Knut Ångström_, Nov 27 2016
%E Formula clarified by _Harvey P. Dale_, Dec 08 2017
|