login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A091938 Smallest prime between 2^n and 2^(n+1), having a maximal number of 1's in binary representation. 7
3, 7, 11, 31, 47, 127, 191, 383, 991, 2039, 3583, 8191, 15359, 20479, 63487, 131071, 245759, 524287, 786431, 1966079, 4128767, 7323647, 14680063, 33546239, 67108351, 100646911, 260046847, 536739839, 1073479679, 2147483647 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
COMMENTS
A091937(n) = A000120(a(n)).
LINKS
MATHEMATICA
NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; p = 2; Do[c = 0; While[p < 2^n, b = Count[ IntegerDigits[p, 2], 1]; If[c < b, c = b; q = p]; p = NextPrim[p]]; Print[q], {n, 1, 30}] (* Robert G. Wilson v, Feb 21 2004 *)
b[n_] := Min[ Select[ FromDigits[ #, 2] & /@ (Join[{1}, #, {1}] & /@ Permutations[ Join[{0}, Table[1, {n - 2}]]]), PrimeQ[ # ] &]]; c[n_] := Min[ Select[ FromDigits[ #, 2] & /@ (Join[{1}, #, {1}] & /@ Permutations[ Join[{0, 0}, Table[1, {n - 3}]]]), PrimeQ[ # ] &]]; f[n_] := If[ PrimeQ[2^(n + 1) - 1], 2^(n + 1) - 1, If[ PrimeQ[ b[n]], b[n], c[n]]]; Table[ f[n], {n, 30}] (* Robert G. Wilson v *)
PROG
(Python)
from sympy import isprime
from sympy.utilities.iterables import multiset_permutations
def A091938(n):
for i in range(n, -1, -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
Sequence in context: A274134 A131588 A361680 * A333424 A186893 A051919
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Feb 14 2004
EXTENSIONS
More terms from Robert G. Wilson v, Feb 20 2004
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 16 14:02 EDT 2024. Contains 371735 sequences. (Running on oeis4.)