A181191 Number of n X n matrices containing a permutation of 1..n*n in increasing order rowwise, columnwise, diagonally and (downwards) antidiagonally.
1, 1, 4, 169, 141696, 3777546912, 4673805856338368, 368253691037579094795185, 2426023001499238992505630883146240, 1697356437632520242875237327471631991584394752, 156101219875805260212264222801658705937606174957553142873088
Offset: 1
Keywords
Examples
All solutions for 3 X 3: ..1..2..3....1..2..3....1..2..4....1..2..4 ..4..5..6....4..5..7....3..5..6....3..5..7 ..7..8..9....6..8..9....7..8..9....6..8..9
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..20
Programs
-
Maple
b:= proc(l) option remember; local n; n:= nops(l); `if`({l[]}={0}, 1, add(`if`((i=1 or l[i-1]<=l[i]) and l[i]> `if`(i=n, 0, l[i+1]), b(subsop(i=l[i]-1, l)), 0), i=1..n)) end: a:= n-> b([n$n]): seq(a(n), n=1..10); # Alois P. Heinz, Jul 24 2012
-
Mathematica
b[l_] := b[l] = With[{n = Length[l]}, If[Union[l]=={0}, 1, Sum[If[(i==1 || l[[i-1]] <= l[[i]]) && l[[i]] > If[i==n, 0, l[[i+1]]], b[ReplacePart[l, i->l[[i]]-1]], 0], {i, 1, n}]]]; a[n_] := b[Table[n, {n}]]; Table[a[n], {n, 1, 11}] (* Jean-François Alcover, May 10 2022, after Alois P. Heinz *)
Extensions
a(10)-a(16) from Alois P. Heinz, Jul 24 2012