login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Bisection of A001358.
1

%I #14 Oct 23 2024 11:42:49

%S 4,9,14,21,25,33,35,39,49,55,58,65,74,82,86,91,94,106,115,119,122,129,

%T 134,142,145,155,159,166,177,183,187,201,203,206,213,215,218,221,235,

%U 247,253,259,265,274,287,291,298,301,303,309,319,323,327,334,339,346

%N Bisection of A001358.

%p P:=[seq(ithprime(n),n=1..100)]: B:={seq(seq(P[i]*P[j],j=1..100),i=1..100)}:C:={seq(B[k],k=1..140)}: seq(C[2*j-1],j=1..70); # _Emeric Deutsch_, Dec 14 2004

%o (Python)

%o from math import isqrt

%o from sympy import primepi, primerange

%o def A099980(n):

%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): return int((n<<1)+1+x+((t:=primepi(s:=isqrt(x)))*(t-1)>>1)-sum(primepi(x//p) for p in primerange(s+1)))

%o return bisection(f,(n<<1)+1,(n<<1)+1) # _Chai Wah Wu_, Oct 23 2024

%Y Cf. A001358.

%K nonn,easy

%O 0,1

%A _N. J. A. Sloane_, Nov 19 2004

%E More terms from _Emeric Deutsch_, Dec 14 2004