|
Spring Semester 2005
|
You can finally use Java to solve the problem from Homework Zero:
Implement the following procedure to construct magic
Here's the
Calculate the
n-by-n squares;
n is odd.
1 in the middle of the bottom row.
k has been placed in the (i, j) square,
place k+1 into the square to the right and down,
wrapping around the borders.
then you must move to the square straight up instead.
5-by-5 square that you get if you follow this method:
Check that the square above is magic.
11 18 25 2 9
10 12 19 21 3
4 6 13 20 22
23 5 7 14 16
17 24 1 8 15
3-by-3, 7-by-7 and 13-by-13 magic squares.
Last updated by Adrian German for A201/A597/I210 on
Sun Apr 17 21:35:05 EST 2005