|
|
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; 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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,4
|
|
LINKS
|
|
|
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
|
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
|
|
MATHEMATICA
|
c[x_] := Module[{},
Length[Select[Permutations[x],
First[#] != 0 && PrimeQ[FromDigits[#, 2]] &]]];
Return[Max[Map[c, DeleteDuplicatesBy[Tuples[Range[0, 1], n],
Table[Count[#, i], {i, 0, 1}] &]]]]];
|
|
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))
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,nonn,changed
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|