login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A087039
If n is prime then 1 else 2nd largest prime factor of n.
7
1, 1, 1, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 1, 3, 1, 2, 3, 2, 1, 2, 5, 2, 3, 2, 1, 3, 1, 2, 3, 2, 5, 3, 1, 2, 3, 2, 1, 3, 1, 2, 3, 2, 1, 2, 7, 5, 3, 2, 1, 3, 5, 2, 3, 2, 1, 3, 1, 2, 3, 2, 5, 3, 1, 2, 3, 5, 1, 3, 1, 2, 5, 2, 7, 3, 1, 2, 3, 2, 1, 3, 5, 2, 3, 2, 1, 3, 7, 2, 3, 2, 5, 2, 1, 7, 3, 5, 1, 3
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
FORMULA
a(n) = A006530(A052126(n)) = A006530(n/A006530(n));
A087040(n) = a(A002808(n)).
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