login

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

A378479
Numbers k such that in base 2 the k-th composite is a substring of the k-th prime.
2
16, 17, 98, 210, 654, 3386, 3387, 3388, 3389, 3392, 3395, 3397, 3398, 3401, 3504, 4806, 22401, 27997, 30930, 75126, 109303, 119466, 119467, 221344, 265167, 391691, 412566, 772432, 949072, 1451888, 2456497, 2739020, 2963199, 4942623, 4942624, 4942631, 4942632, 4942634, 4942636, 4942637, 4942638
OFFSET
1,1
COMMENTS
Numbers k such that A175349(k) = prime(k).
EXAMPLE
a(3) = 98 is a term because the 98th composite is 130 which is 10000010 in binary, the 98th prime is 521 which is 1000001001 in binary, and the first 8 bits of 1000001001 are 10000010.
MAPLE
g:= proc(p, c)
StringTools:-Search(convert(convert(c, binary), string),
convert(convert(p, binary), string)) <> 0
end proc:
nextcomp:= proc(c)
if isprime(c+1) then c+2 else c+1 fi
end proc:
p:= 1: c:= 2: Res:= NULL: count:= 0:
for n from 1 to 10^7 do
p:= nextprime(p);
c:= nextcomp(c);
if g(p, c) then Res:= Res, n; count:= count+1; fi
od:
R;
MATHEMATICA
p = 1;
c = 2;
Table[
p = NextPrime[p];
c += If[PrimeQ[c + 1], 2, 1];
mod = 2^BitLength[c];
test = NestWhile[BitShiftRight, p,
BitAnd[#, mod - 1] != c && # > c &];
If[test >= c, n, Nothing]
, {n, 10^5}]
(* David Trimas, Dec 01 2024 *)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Robert Israel, Nov 28 2024
STATUS
approved