login
Smallest prime which when rotated through all its binary places produces n primes, not counting any repeats.
2

%I #32 Jan 25 2023 11:50:13

%S 2,5,11,43,167,2143,2423,2687,41903,548543,711679,786431,9010423,

%T 10452461,10065788911,34762189783,37974998491,39115947389

%N Smallest prime which when rotated through all its binary places produces n primes, not counting any repeats.

%C It is probably not the case that this always produces the same bit cycle as A088148. - _Franklin T. Adams-Watters_, Mar 29 2014

%e a(5) = 167 because 167 in base two is 10100111. This will produce eight possible new numbers; 01001111 = 79, 10011110 = 158, 00111101 = 61, 01111010 = 122, 11110100 = 244, 11101001 = 233, 11010011 = 211 and back to the beginning 10100111 = 167. Of those eight numbers (79, 158, 61, 122, 244, 233, 211 & 167) only five of them are primes. Notice that this is the same bit cycle as in A088148 but rotated differently.

%t f[n_] := Count[ PrimeQ[ Union[ Table[ FromDigits[ RotateLeft[ IntegerDigits[n, 2], i], 2], {i, 1, Floor[ Log[2, n] + 1]}]]], True]; NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; a = Table[0, {100}]; k = 2; Do[c = f[k]; If[c < 101 && a[[c]] == 0, a[[c]] = k]; k = NextPrim[k], {n, 1, 2750000}]; a

%o (Python 3.10+)

%o from itertools import count

%o from sympy import isprime

%o def A088149(n):

%o if n == 1: return 2

%o for p in count((1<<n)-1,2):

%o if p.bit_count() >= n and isprime(p):

%o m = p.bit_length()

%o l = 1<<m-1

%o k, cset, q = l-1, {p}, p

%o for _ in range(m-1):

%o p = bool(p&l)+((p&k)<<1)

%o if p not in cset and isprime(p):

%o cset.add(p)

%o if len(cset) == n:

%o return q # _Chai Wah Wu_, Jan 23 2023

%Y Cf. A088148.

%K nonn,base,more

%O 1,1

%A _Robert G. Wilson v_, Sep 19 2003

%E Edited by _Franklin T. Adams-Watters_, Mar 29 2014

%E a(15) from _Chai Wah Wu_, Jan 23 2023

%E a(16) from _Chai Wah Wu_, Jan 24 2023

%E a(17)-a(18) from _Chai Wah Wu_, Jan 25 2023