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.

A060847 Difference between a nontrivial prime power (A246547) and the previous prime.

Original entry on oeis.org

1, 1, 2, 3, 2, 4, 1, 2, 3, 2, 8, 12, 1, 2, 2, 5, 6, 6, 2, 3, 6, 6, 2, 2, 8, 3, 4, 2, 12, 2, 9, 8, 18, 2, 2, 6, 4, 12, 2, 3, 6, 4, 2, 6, 12, 8, 2, 6, 2, 1, 6, 8, 2, 2, 14, 4, 6, 2, 6, 2, 3, 20, 2, 12, 2, 2, 8, 14, 10, 18, 8, 6, 2, 2, 2, 12, 12, 19, 2, 6, 6, 20, 2, 2, 2, 8, 8, 2, 2, 8, 20, 12, 15, 2, 4
Offset: 1

Views

Author

Labos Elemer, May 03 2001

Keywords

Comments

a(n)=1 only for some powers of 2.

Examples

			78125=5^7 follows 78121, the difference is 4.
		

Crossrefs

Programs

  • Maple
    N:= 10^5: # to consider prime powers <= N
    P:= select(isprime,[2,seq(i,i=3..floor(sqrt(N)),2)]):
    PP:= sort([seq(seq(p^k,k=2..ilog[p](N)),p=P)]):
    map(t -> t - prevprime(t), PP); # Robert Israel, Nov 13 2024
  • Python
    from sympy import primepi, integer_nthroot, prevprime
    def A060847(n):
        def f(x): return int(n+x-sum(primepi(integer_nthroot(x,k)[0]) for k in range(2,x.bit_length())))
        def bisection(f,kmin=0,kmax=1):
            while f(kmax) > kmax: kmax <<= 1
            while kmax-kmin > 1:
                kmid = kmax+kmin>>1
                if f(kmid) <= kmid:
                    kmax = kmid
                else:
                    kmin = kmid
            return kmax
        return (a:=bisection(f,n,n))-prevprime(a) # Chai Wah Wu, Sep 13 2024

Formula

a(n) = A246547(n)-prevprime(A246547(n)) = A246547(n)-A049711(A246547(n)).