|
|
A333877
|
|
a(n) is the largest prime 2^(n-1) <= p < 2^n maximizing the Hamming weight of all primes in this interval.
|
|
3
|
|
|
3, 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, 65519, 131071, 262139, 524287, 1048573, 2097143, 4194301, 8388587, 16777213, 33546239, 67108859, 134217467, 260046847, 536870909, 1073741567, 2147483647, 4294967291, 8589934583, 16911433727
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
2,1
|
|
COMMENTS
|
|
|
LINKS
|
|
|
MAPLE
|
a:= proc(n) option remember; local i, p;
for i from 0 do p:= max(select(isprime, map(l-> add(l[j]*
2^(j-1), j=1..n), combinat[permute]([1$(n-i), 0$i]))));
if p>0 then break fi
od; p
end:
|
|
MATHEMATICA
|
a[n_] := a[n] = MaximalBy[{#, DigitCount[#, 2, 1]}& /@ Select[Range[ 2^(n-1), 2^n-1], PrimeQ], Last][[-1, 1]];
|
|
PROG
|
(PARI) for(n=2, 30, my(hmax=0, pmax); forprime(p=2^(n-1), 2^n, my(h=hammingweight(p)); if(h>=hmax, pmax=p; hmax=h)); print1(pmax, ", "))
(Python)
from sympy import isprime
from sympy.utilities.iterables import multiset_permutations
for i in range(n-1, -1, -1):
q = 2**n-1
for d in multiset_permutations('0'*i+'1'*(n-1-i)):
p = q-int(''.join(d), 2)
if isprime(p):
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|