%I #17 Aug 27 2024 09:16:21
%S 1,1,2,2,3,6,12,36,156,520,1920,5760,12600,39900,210140,844984,
%T 2871876,8784783,29392449,123405524,726794464,3669378736,20998365592,
%U 139906305272,770298602024,4979077340664,35706521898618,187318543647373,1117410697347693,7335115455487050,46292557037334300
%N Number of permutations p of (1,2,...,n) such that 1+k+p(k) is prime for all k=1,2,...,n.
%F 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
%e 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).
%p 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);
%t a[n_] := a[n] = Permanent[Table[Boole[PrimeQ[i+j+1]], {i, 1, n}, {j, 1, n}]];
%t Table[Print[n, " ", a[n]]; a[n], {n, 1, 20}] (* _Jean-François Alcover_, Aug 27 2024, after _T. D. Noe_ *)
%o (PARI) a(n) = matpermanent(matrix(n,n,i,j,isprime(i+j+1))); \\ _Michel Marcus_, Aug 27 2024
%K nonn,changed
%O 1,3
%A _Emeric Deutsch_, Mar 27 2005
%E More terms from _Ryan Propper_, Mar 29 2007
%E More terms from _T. D. Noe_, Oct 16 2007
%E a(21)-a(31) from _Robert Gerbicz_, Nov 27 2010
|