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.

A031218 Largest prime power <= n.

Original entry on oeis.org

1, 2, 3, 4, 5, 5, 7, 8, 9, 9, 11, 11, 13, 13, 13, 16, 17, 17, 19, 19, 19, 19, 23, 23, 25, 25, 27, 27, 29, 29, 31, 32, 32, 32, 32, 32, 37, 37, 37, 37, 41, 41, 43, 43, 43, 43, 47, 47, 49, 49, 49, 49, 53, 53, 53, 53, 53, 53, 59, 59, 61, 61, 61, 64, 64, 64, 67, 67, 67, 67, 71, 71
Offset: 1

Views

Author

Keywords

Comments

The length of the m-th run of {a(n)} is the length of the (m+1)-st run of A000015 for m > 1. - Colin Linzer, Mar 08 2024

Crossrefs

Programs

  • Haskell
    a031218 n = last $ takeWhile (<= n) a000961_list
    -- Reinhard Zumkeller, Apr 25 2011
    
  • Maple
    A031218 := proc(n)
        local a,pi,p,m ;
        a := 1 ;
        for pi from 1 do
            p := ithprime(pi) ;
            if p > n then
                return a;
            end if;
            for m from 0 do
                if p^m > n then
                    break;
                elif p^m <= n then
                    a := max(a,p^m) ;
                end if;
            end do:
        end do:
        a ;
    end proc:
    seq(A031218(n),n=1..40) ; # R. J. Mathar, Jul 20 2025
  • PARI
    a(n)=if(n<1,0, while(matsize(factor(n))[1]>1,n--); n)
    
  • Python
    from sympy import factorint
    def A031218(n): return next(filter(lambda m:len(factorint(m))<=1, range(n,0,-1))) # Chai Wah Wu, Oct 25 2024

Formula

a(n) = n - A378457(n). - R. J. Mathar, Jul 20 2025
a(n) = A000961(A065515(n)). - Ridouane Oudra, Aug 22 2025

Extensions

More terms from Erich Friedman