The n queens downside is to position on an n × n chessboard n queens in order that none assaults every other. This implies there is just one queen on each horizontal, vertical, and diagonal line.
When n is a prime quantity ≥ 5, it’s enough to position the queens on a line that has slope 2, 3, 4, …, n − 2. (The slope can’t be 1 as a result of that’s a diagonal. And it can’t be n − 1 as a result of n − 1 = −1 mod n can be a diagonal.) [1]
Right here we think about reverse edges of the board being joined collectively. Geometrically, this makes the chessboard a torus (donut). Algebraically, the factors on a line of slope s have the coordinates
(a + ok, b + ks)
the place addition is carried out mod n.
All options to the n queens downside have this manner when n = 5. Some options may have this manner for bigger prime values of n however not all.
For instance, when n = 7, here’s a resolution the place all of the queens are on a line of slope 2.
However right here is one other resolution the place the queens don’t all lie on a line of fixed slope.

Associated posts
[1] W. H. Bussey. A Be aware on the Drawback of the Eight Queens. The American Mathematical Month-to-month, Vol. 29, No. 7 (August 1922), pp. 252–253
