Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
A065843
Let u be any string of n digits from {0,1}; let f(u) = number of distinct primes, not beginning with 0, formed by permuting the digits of u to a base-2 number; then a(n) = max_u f(u).
11
0, 1, 1, 2, 2, 3, 5, 12, 11, 24, 34, 79, 105, 194, 362, 734, 1143, 2045, 3872, 7758, 13001, 23902, 45539, 90436, 159510, 296210, 563833, 1110387, 2030754, 3876871, 7333827, 14353074, 26730538, 51246344, 97529176, 190928828, 358117285, 694240090, 1324674524, 2587693929, 4903604087, 9547001123
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
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