login
Numbers k such that A018252(k+1) = A018252(k) + 1. In other words, the k-th nonprime number is 1 less than the next.
10

%I #12 Sep 15 2024 22:02:31

%S 4,5,8,9,12,13,15,16,17,18,21,22,23,24,26,27,30,31,33,34,35,36,38,39,

%T 40,41,44,45,46,47,49,50,53,54,55,56,58,59,61,62,63,64,66,67,68,69,70,

%U 71,73,74,77,78,81,82,84,85,86,87,88,89,90,91,92,93,94,95

%N Numbers k such that A018252(k+1) = A018252(k) + 1. In other words, the k-th nonprime number is 1 less than the next.

%e The nonprime numbers are 1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, ... which increase by 1 after term 4, term 5, term 8, etc.

%t Join@@Position[Differences[Select[Range[100],!PrimeQ[#]&]],1]

%o (Python)

%o from sympy import primepi

%o def A375926(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 n+bisection(lambda y:primepi(x+1+y))-1

%o return bisection(f,n,n) # _Chai Wah Wu_, Sep 15 2024

%Y The complement appears to be A014689, except the first term.

%Y Positions of 1's in A065310 (see also A054546, A073783).

%Y First differences are A373403 (except first).

%Y The version for non-prime-powers is A375713, differences A373672.

%Y The version for prime-powers is A375734, differences A373671.

%Y The version for non-perfect-powers is A375740.

%Y The version for composite numbers is A375929.

%Y A000040 lists the prime numbers, differences A001223.

%Y A018252 lists the nonprimes, exclusive A002808.

%Y A046933 counts composite numbers between primes.

%Y Cf. A000961, A006549, A057820, A176246, A246655, A251092, A375708.

%K nonn

%O 1,1

%A _Gus Wiseman_, Sep 11 2024