%I #24 Sep 15 2024 22:00:52
%S 2,2,0,2,3,0,2,0,4,3,2,2,3,3,2,0,1,3,5,5,2,1,1,5,1,7,0,5,2,4,5,1,5,2,
%T 7,3,2,2,6,9,4,4,0,7,8,2,7,4,4,8,1,1,4,4,9,7,2,1,9,10,6,1,0,2,0,9,12,
%U 7,4,12,6,5,4,5,12,0,8,3,3,10,8,0,2,13,2,13,10,10,1,15,0,7,9,9,3,13,7,4,0,7,5,4,13,2
%N Number of primes between successive powerful numbers (A001694).
%H Amiram Eldar, <a href="/A240590/b240590.txt">Table of n, a(n) for n = 1..10000</a>
%e a(9) = 4 because A001694(9) = 36, A001694(10) = 49, and there are 4 primes between them: 37, 41, 43 and 47.
%o (PARI)
%o ispowerful(n)={local(h);if(n==1,h=1,h=(vecmin(factor(n)[, 2])>1));return(h)}
%o proxpowerful(n)={local(k);k=n+1;while(!ispowerful(k),k+=1);return(k)}
%o {for(i=1,5000,if(ispowerful(i),m=proxpowerful(i);p=primepi(m)-primepi(i);print1(p, ", ")))}
%o (Python)
%o from math import isqrt
%o from sympy import mobius, integer_nthroot, primepi
%o def A240590(n):
%o def squarefreepi(n): return int(sum(mobius(k)*(n//k**2) for k in range(1, isqrt(n)+1)))
%o def bisection(f,kmin=0,kmax=1):
%o while f(kmax) > kmax: kmax <<= 1
%o while kmax-kmin > 1:
%o kmid = kmax+kmin>>1
%o if f(kmid) <= kmid:
%o kmax = kmid
%o else:
%o kmin = kmid
%o return kmax
%o def f(x):
%o c, l = n+x, 0
%o j = isqrt(x)
%o while j>1:
%o k2 = integer_nthroot(x//j**2,3)[0]+1
%o w = squarefreepi(k2-1)
%o c -= j*(w-l)
%o l, j = w, isqrt(x//k2**3)
%o c -= squarefreepi(integer_nthroot(x,3)[0])-l
%o return c
%o return -primepi(a:=bisection(f,n,n))+primepi(bisection(lambda x:f(x)+1,a,a)) # _Chai Wah Wu_, Sep 15 2024
%Y Cf. A001694, A240591.
%K nonn
%O 1,1
%A _Antonio Roldán_, Apr 08 2014