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.

A099980 Bisection of A001358.

This page as a plain text file.
%I A099980 #14 Oct 23 2024 11:42:49
%S A099980 4,9,14,21,25,33,35,39,49,55,58,65,74,82,86,91,94,106,115,119,122,129,
%T A099980 134,142,145,155,159,166,177,183,187,201,203,206,213,215,218,221,235,
%U A099980 247,253,259,265,274,287,291,298,301,303,309,319,323,327,334,339,346
%N A099980 Bisection of A001358.
%p A099980 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 A099980 (Python)
%o A099980 from math import isqrt
%o A099980 from sympy import primepi, primerange
%o A099980 def A099980(n):
%o A099980     def bisection(f,kmin=0,kmax=1):
%o A099980         while f(kmax) > kmax: kmax <<= 1
%o A099980         while kmax-kmin > 1:
%o A099980             kmid = kmax+kmin>>1
%o A099980             if f(kmid) <= kmid:
%o A099980                 kmax = kmid
%o A099980             else:
%o A099980                 kmin = kmid
%o A099980         return kmax
%o A099980     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 A099980     return bisection(f,(n<<1)+1,(n<<1)+1) # _Chai Wah Wu_, Oct 23 2024
%Y A099980 Cf. A001358.
%K A099980 nonn,easy
%O A099980 0,1
%A A099980 _N. J. A. Sloane_, Nov 19 2004
%E A099980 More terms from _Emeric Deutsch_, Dec 14 2004