login
The largest divisor of n that is the sum of 2 squares.
2

%I #7 Mar 08 2024 08:09:16

%S 1,2,1,4,5,2,1,8,9,10,1,4,13,2,5,16,17,18,1,20,1,2,1,8,25,26,9,4,29,

%T 10,1,32,1,34,5,36,37,2,13,40,41,2,1,4,45,2,1,16,49,50,17,52,53,18,5,

%U 8,1,58,1,20,61,2,9,64,65,2,1,68,1,10,1,72,73,74,25

%N The largest divisor of n that is the sum of 2 squares.

%H Amiram Eldar, <a href="/A371015/b371015.txt">Table of n, a(n) for n = 1..10000</a>

%F Multiplicative with a(p^e) = p^(2*floor(e/2)) if p == 3 (mod 4), and p^e otherwise.

%F a(n) = n / A363340(n).

%F a(n) = n if and only if n is in A001481.

%F a(n) = 1 if and only if n is in A167181.

%t f[p_, e_] := If[Mod[p, 4] == 3, p^(2*Floor[e/2]), p^e]; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100]

%o (PARI) a(n) = {my(f = factor(n)); prod(i = 1, #f~, f[i, 1]^if(f[i, 1]%4 == 3, 2*(f[i, 2]\2), f[i, 2]));}

%Y Cf. A001481, A167181, A363340, A371014.

%K nonn,easy,mult

%O 1,2

%A _Amiram Eldar_, Mar 08 2024