login
A103687
Number of permutations p of (1,2,...,n) such that 1+k+p(k) is prime for all k=1,2,...,n.
0
1, 1, 2, 2, 3, 6, 12, 36, 156, 520, 1920, 5760, 12600, 39900, 210140, 844984, 2871876, 8784783, 29392449, 123405524, 726794464, 3669378736, 20998365592, 139906305272, 770298602024, 4979077340664, 35706521898618, 187318543647373, 1117410697347693, 7335115455487050, 46292557037334300
OFFSET
1,3
FORMULA
a(n) = permanent(m), where the n X n matrix m is defined by m(i,j) = 1 or 0, depending on whether i+j+1 is prime or composite respectively. - T. D. Noe, Oct 16 2007
EXAMPLE
a(3)=2 because we have 123 (1+1+1, 1+2+2, 1+3+3 are all prime) and 321 (1+1+3, 1+2+2, 1+3+1 are all prime).
MAPLE
with(combinat): a:=proc(n) local P, ct, i: P:=permute(n): ct:=0: for i from 1 to n! do if [seq(isprime(1+j+P[i][j]), j=1..n)]=[seq(true, i=1..n)] then ct:=ct+1 else ct:=ct fi od:end: seq(a(n), n=1..8);
MATHEMATICA
a[n_] := a[n] = Permanent[Table[Boole[PrimeQ[i+j+1]], {i, 1, n}, {j, 1, n}]];
Table[Print[n, " ", a[n]]; a[n], {n, 1, 20}] (* Jean-François Alcover, Aug 27 2024, after T. D. Noe *)
PROG
(PARI) a(n) = matpermanent(matrix(n, n, i, j, isprime(i+j+1))); \\ Michel Marcus, Aug 27 2024
CROSSREFS
Sequence in context: A307241 A064674 A095902 * A166678 A032908 A192366
KEYWORD
nonn
AUTHOR
Emeric Deutsch, Mar 27 2005
EXTENSIONS
More terms from Ryan Propper, Mar 29 2007
More terms from T. D. Noe, Oct 16 2007
a(21)-a(31) from Robert Gerbicz, Nov 27 2010
STATUS
approved