cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A087039 If n is prime then 1 else 2nd largest prime factor of n.

This page as a plain text file.
%I A087039 #24 Feb 16 2025 08:32:50
%S A087039 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,
%T A087039 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,
%U A087039 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
%N A087039 If n is prime then 1 else 2nd largest prime factor of n.
%H A087039 Charles R Greathouse IV, <a href="/A087039/b087039.txt">Table of n, a(n) for n = 1..10000</a>
%H A087039 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/GreatestPrimeFactor.html">Greatest Prime Factor</a>
%F A087039 a(n) = A006530(A052126(n)) = A006530(n/A006530(n));
%F A087039 A087040(n) = a(A002808(n)).
%p A087039 A087039 := proc(n)
%p A087039     local pset ,t;
%p A087039     if isprime(n) or n= 1 then
%p A087039         1;
%p A087039     else
%p A087039         pset := [] ;
%p A087039         for p in ifactors(n)[2] do
%p A087039             pset := [op(pset),seq(op(1,p),t=1..op(2,p))] ;
%p A087039         end do:
%p A087039         op(-2,sort(pset)) ;
%p A087039     end if;
%p A087039 end proc: # _R. J. Mathar_, Sep 14 2012
%t A087039 gpf[n_] := FactorInteger[n][[-1, 1]];
%t A087039 a[n_] := If[PrimeQ[n], 1, gpf[n/gpf[n]]];
%t A087039 Array[a, 105] (* _Jean-François Alcover_, Dec 16 2021 *)
%o A087039 (Haskell)
%o A087039 a087039 n | null ps   = 1
%o A087039           | otherwise = head ps
%o A087039           where ps = tail $ reverse $ a027746_row n
%o A087039 -- _Reinhard Zumkeller_, Oct 03 2012
%o A087039 (Python)
%o A087039 from sympy import factorint
%o A087039 def a(n):
%o A087039     pf = factorint(n, multiple=True)
%o A087039     return 1 if len(pf) < 2 else pf[-2]
%o A087039 print([a(n) for n in range(1, 103)]) # _Michael S. Branicky_, Dec 16 2021
%Y A087039 Cf. A002808, A006530, A085392, A087040.
%Y A087039 Cf. A027746, A052126.
%K A087039 nonn,easy
%O A087039 1,4
%A A087039 _Reinhard Zumkeller_, Aug 01 2003