login
A060847
Difference between a nontrivial prime power (A246547) and the previous prime.
1
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,3
COMMENTS
a(n)=1 only for some powers of 2.
LINKS
FORMULA
a(n) = A246547(n)-prevprime(A246547(n)) = A246547(n)-A049711(A246547(n)).
EXAMPLE
78125=5^7 follows 78121, the difference is 4.
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
PROG
(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
KEYWORD
nonn
AUTHOR
Labos Elemer, May 03 2001
STATUS
approved