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.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Aug 01 2003

Keywords

Crossrefs

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

Formula

a(n) = A006530(A052126(n)) = A006530(n/A006530(n));
A087040(n) = a(A002808(n)).