OFFSET
1,8
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
MAPLE
f:= proc(n) local F, t;
if issqr(n) then
n/min(numtheory:-factorset(n))^2
else
F:= ifactors(n)[2];
mul(t[1]^(2*floor(t[2]/2)), t=F)
fi
end proc:
f(1):= 1:
map(f, [$1..100]); # Robert Israel, Nov 20 2023
MATHEMATICA
Join[{1}, Table[Last[Select[Divisors[n], # < n && IntegerQ[Sqrt[#]] &]], {n, 2, 100}]]
f[p_, e_] := p^(2*Floor[e/2]); a[n_] := Module[{fct = FactorInteger[n]}, Times @@ f @@@ fct/If[AllTrue[fct[[;; , 2]], EvenQ], fct[[1, 1]]^2, 1]]; Array[a, 100] (* Amiram Eldar, Oct 19 2023 *)
PROG
(PARI) a(n) = if (n==1, 1, my(d=divisors(n)); vecmax(select(issquare, Vec(d, #d-1)))); \\ Michel Marcus, Oct 17 2023
(Python)
from math import prod
from sympy import factorint
def A365837(n):
if n<=1: return 1
f = factorint(n)
return prod(p**(e&-2) for p, e in f.items())//(min(f)**2 if all(e&1^1 for e in f.values()) else 1) # Chai Wah Wu, Oct 20 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Ilya Gutkovskiy, Oct 17 2023
STATUS
approved