A087039 If n is prime then 1 else 2nd largest prime factor of n.
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
Links
- Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
- Eric Weisstein's World of Mathematics, Greatest Prime Factor
Programs
-
Haskell
a087039 n | null ps = 1 | otherwise = head ps where ps = tail $ reverse $ a027746_row n -- Reinhard Zumkeller, Oct 03 2012
-
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 *)
-
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