a too-short sequence related to Latin squares

Brendan McKay bdm at cs.anu.edu.au
Wed Sep 8 06:18:43 CEST 2004


* hv at crypt.org <hv at crypt.org> [040908 11:00]:
> Sterten at aol.com wrote:
> :>> How many n X n squares are there,  filled with
> :>> the numbers 1...n, such that in row or column  k,
> :>> for all k = 1...n, the number k appears at least  once?
> :
> :1,6,2683,223041730,6009583845720101,81562450515482338061230306,  different 
> :matrices

1
6
2683
223041730
6009583845720101
81562450515482338061230306
801231178966121521807378920617005246471
7747118609267949193978742640152633949388622796278760450
96260050927125657231057045653340232713369826309730222706933915414681058441
...
and a(100) has 19961 digits,

and by now you are suspecting I have a formula.

Define
   A(i) = (n-1)^i*n^(n-i) - (n-2)^i*(n-1)^(n-i)          (i=0..n)
   B(i) = (n-1)^i*n^(n-i) - (n-2)^(i-1)*(n-1)^(n-i+1)    (i=1..n)
Then
   a(n) = sum( binomial(n,i)*(-1)^i*A(i)^(n-i)*B(i)^i, i=0..n ).

Interprettation:
   A(i) is the number of ways of choosing row j, say R, such that it
      has at least one j, and i specified positions R[k[1]], ..., R[k[i]]
      that DO NOT include position R[j] don't have R[k[m]]=k[m] for any m.
   B(i) is the number of ways of choosing row j, say R, such that it
      has at least one j, and i specified positions R[k[1]], ..., R[k[i]]
      that DO include position R[j] don't have R[k[m]]=k[m] for any m.

   Now  A(i)^(n-i) * B(i)^i  is the number of ways of choosing all the
   rows such that row j has at least one j for each j, and such that
   a specified set of i columns each do not have an entry equal to the
   column number.

   Now you can see that the given formula for a(n) is just
   inclusion-exclusion over the erroneous columns, always working with
   matrices having valid rows.

Can someone do the OEIS thing with this please?

Cheers, Brendan.





More information about the SeqFan mailing list