OFFSET
1,1
COMMENTS
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..1000
MATHEMATICA
NextPrim[ n_] := Block[ {k = n + 1}, While[ !PrimeQ[ k], k++ ]; k]; p = 2; Do[ c = Infinity; While[ p < 2^n, b = Count[ IntegerDigits[ p, 2], 1]; If[ c > b, c = b; q = p]; p = NextPrim[ p]; If[ c < 4, p = NextPrim[ 2^n]; Continue[ ]]]; Print[ q], {n, 2, 32}] (* Robert G. Wilson v, Feb 18 2004 *)
b[ n_ ] := Min[ Select[ FromDigits[ #, 2 ] & /@ (Join[ {1}, #, {1} ] & /@ Permutations[ Join[ {1}, Table[ 0, {n - 2} ] ] ]), PrimeQ[ # ] & ] ]; c[ n_ ] := Min[ Select[ FromDigits[ #, 2 ] & /@ (Join[ {1}, #, {1} ] & /@ Permutations[ Join[ {1, 1}, Table[ 0, {n - 3} ] ] ]), PrimeQ[ # ] & ] ]; f[ n_ ] := If[ PrimeQ[ 2^n + 1 ], 2^n + 1, If[ PrimeQ[ b[ n ] ], b[ n ], c[ n ] ] ]; Table[ f[ n ], {n, 2, 32} ] (* Robert G. Wilson v *)
PROG
(Python)
from sympy import isprime
from sympy.utilities.iterables import multiset_permutations
def A091936(n):
for i in range(n+1):
q = 2**n
for d in multiset_permutations('0'*(n-i)+'1'*i):
p = q+int(''.join(d), 2)
if isprime(p):
return p # Chai Wah Wu, Apr 08 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Feb 14 2004
EXTENSIONS
More terms from Robert G. Wilson v, Feb 18 2004
STATUS
approved