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
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