Aggressive rooks

Consider a chessboard with n rows and n columns. In how many ways can we
place n rooks so that at least two rooks threaten each other?

For instance, these are two of the ways for n = 6:

Input

Input consists of several numbers 1 ≤ n ≤ 6. A special case with n = 0
marks the end of input.

Output

For every n, print the number of different ways to place n rooks on a
chessboard n × n so that at least two rooks threaten each other. For
every 1 ≤ n ≤ 6, this number has less than 10 digits.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:05:02.432Z

© Jutge.org, 2006–2026.
https://jutge.org
