OFFSET
1,4
EXAMPLE
a(4)=2 because 1011 and 1101 in base-2 notation are primes (11 and 13) and there is no set of three or more 4-digit primes with a common number of ones.
MAPLE
A065843 := proc(n)
local b, u, udgs, uperm, a;
b :=2 ;
a := 0 ;
for u from b^(n-1) to b^n-1 do
udgs := convert(u, base, b) ;
prs := {} ;
for uperm in combinat[permute](udgs) do
if op(-1, uperm) <> 0 then
p := add( op(i, uperm)*b^(i-1), i=1..nops(uperm)) ;
if isprime(p) then
prs := prs union {p} ;
end if;
end if;
end do:
a := max(a, nops(prs)) ;
end do:
a ;
end proc:
for n from 1 do
print(n, A065843(n)) ;
end do: # R. J. Mathar, Apr 23 2016
MATHEMATICA
c[x_] := Module[{},
Length[Select[Permutations[x],
First[#] != 0 && PrimeQ[FromDigits[#, 2]] &]]];
A065843[n_] := Module[{i},
Return[Max[Map[c, DeleteDuplicatesBy[Tuples[Range[0, 1], n],
Table[Count[#, i], {i, 0, 1}] &]]]]];
Table[A065843[n], {n, 1, 19}] (* Robert Price, Mar 30 2019 *)
PROG
(PARI) lista(n) = {my(m = matrix(n, n), c); forprime(i=2, 2^n, b = binary(i); m[#b, hammingweight(b)]++); vector(n, i, vecmax(m[i, ]))} \\ David A. Corneth, Apr 23 2016
(Python)
from sympy import isprime
from itertools import combinations_with_replacement as mc
from sympy.utilities.iterables import multiset_permutations as mp
def a(n): return n-1 if n < 3 else max(sum(1 for p in mp(c) if isprime(int("1"+"".join(p)+"1", 2))) for c in mc("01", n-2))
print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Oct 09 2022
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Sascha Kurz, Nov 24 2001
EXTENSIONS
6 more terms from Sean A. Irvine, Sep 06 2009
a(37)-a(39) from Michael S. Branicky, May 30 2024
a(40)-a(42) from Michael S. Branicky, Jun 14 2024
STATUS
approved