OFFSET
1,5
COMMENTS
Pythagorean triples including primitive ones and non-primitive ones. For a certain n, it may be a leg or the hypotenuse in either a primitive Pythagorean triple, or a non-primitive Pythagorean triple, or both. - Rui Lin, Nov 02 2019
REFERENCES
A. Beiler, Recreations in the Theory of Numbers. New York: Dover, pp. 116-117, 1966.
LINKS
Lars Blomberg, Table of n, a(n) for n = 1..10000
Anonymous, Generator of all Pythagorean triples that include a given number [Internet Archive Wayback Machine]
Ron Knott, Pythagorean Triples and Online Calculators
F. Richman, Pythagorean Triples
A. Tripathi, On Pythagorean triples containing a fixed integer, Fib. Q., 46/47 (2008/2009), 331-340. See Theorem 8.
Eric Weisstein's World of Mathematics, Pythagorean Triple
FORMULA
EXAMPLE
From Rui Lin, Nov 02 2019: (Start)
n=25 is the least number which meets all of following cases:
1. 25 is a leg of a primitive Pythagorean triple (25,312,313), so A024361(25)=1;
2. 25 is the hypotenuse of a primitive Pythagorean triple (7,24,25), so A024362(25)=1;
3. 25 is a leg of a non-primitive Pythagorean triple (25,60,65), so A328708(25)=1;
4. 25 is the hypotenuse of a non-primitive Pythagorean triple (15,20,25), so A328712(25)=1;
5. Combination 1. and 3. means A046079(25)=2;
6. Combination 2. and 4. means A046080(25)=2;
7. Combination 1. and 2. means A024363(25)=2;
8. Combination 3. and 4. means A328949(25)=2;
9. Combination of 1., 2., 3., and 4. means A046081(25)=4. (End)
MATHEMATICA
a[1] = 0; a[n_] := Module[{f}, f = Select[FactorInteger[n], Mod[#[[1]], 4] == 1&][[All, 2]]; (DivisorSigma[0, If[OddQ[n], n, n/2]^2]-1)/2 + (Times @@ (2*f+1) - 1)/2]; Array[a, 99] (* Jean-François Alcover, Jul 19 2017 *)
PROG
(PARI) a(n) = {oddn = n/(2^valuation(n, 2)); f = factor(oddn); for (k=1, #f~, if ((f[k, 1] % 4) != 1, f[k, 2] = 0); ); n1 = factorback(f); if (n % 2, (numdiv(n^2)+numdiv(n1^2))/2 -1, (numdiv((n/2)^2)+numdiv(n1^2))/2 -1); } \\ Michel Marcus, Mar 07 2016
(Python)
from sympy import factorint
def a(n):
p1, p2 = 1, 1
for i in factorint(n).items():
if i[0] % 4 == 1:
p2 *= i[1] * 2 + 1
p1 *= i[1] * 2 + 1 - (2 if i[0] == 2 else 0)
return (p1 + p2)//2 - 1
print([a(n) for n in range(1, 100)]) # Oleg Sorokin, Mar 02 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
Improved name by Bernard Schott, Jan 03 2019
STATUS
approved