OFFSET
1,4
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Greatest Prime Factor
MAPLE
A087039 := proc(n)
local pset , t;
if isprime(n) or n= 1 then
1;
else
pset := [] ;
for p in ifactors(n)[2] do
pset := [op(pset), seq(op(1, p), t=1..op(2, p))] ;
end do:
op(-2, sort(pset)) ;
end if;
end proc: # R. J. Mathar, Sep 14 2012
MATHEMATICA
gpf[n_] := FactorInteger[n][[-1, 1]];
a[n_] := If[PrimeQ[n], 1, gpf[n/gpf[n]]];
Array[a, 105] (* Jean-François Alcover, Dec 16 2021 *)
PROG
(Haskell)
a087039 n | null ps = 1
| otherwise = head ps
where ps = tail $ reverse $ a027746_row n
-- Reinhard Zumkeller, Oct 03 2012
(Python)
from sympy import factorint
def a(n):
pf = factorint(n, multiple=True)
return 1 if len(pf) < 2 else pf[-2]
print([a(n) for n in range(1, 103)]) # Michael S. Branicky, Dec 16 2021
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Reinhard Zumkeller, Aug 01 2003
STATUS
approved