A353589 Number of nondecreasing nonnegative integer quadruples (m,p,q,r) such that m^2 + p^2 + q^2 + r^2 = n^2 and m +- p +- q +- r = +- n.
1, 1, 2, 2, 2, 2, 4, 2, 2, 4, 4, 4, 4, 3, 4, 6, 2, 5, 8, 5, 4, 6, 8, 5, 4, 7, 6, 9, 4, 6, 12, 6, 2, 12, 10, 9, 8, 7, 10, 10, 4, 9, 12, 9, 8, 17, 10, 9, 4, 9, 14, 16, 6, 10, 18, 17, 4, 16, 12, 12, 12, 11, 12, 17, 2, 16, 24, 13, 10, 18, 18, 13, 8, 14, 14, 26, 10, 17, 20, 14, 4, 23
Offset: 0
Keywords
Examples
For n = 1, (0, 0, 0, 1) is the only solution. For n = 2, (0, 0, 0, 2) and (1, 1, 1, 1) are solutions, with 1 + 1 + 1 - 1 = 2.
Programs
-
PARI
apply( {A353589(n, show=0, cnt=0, n2=n^2, e=[1,-1]~)= for(a=0,sqrtint(n2\4), for(b=a,sqrtint((n2-a^2)\3), my(s=[a+b, b-a, a-b, -a-b]); foreach(sum2sqr(n2-a^2-b^2), cd, cd[1] >= b && vecsum(cd)+s[1] >= n && foreach(s, d, (vecsum(cd)+d==n || abs(cd*e+d)==n)&& cnt++&& !(show && print1(concat([a, b], cd)))&& break)))); cnt}, [0..99]) \\ See A133388 for sum2sqr().
Comments