Magic Squares of odd order by Marios Mamzeris
The following is a method of creating any odd-order
associative magic square. I had the idea
of this technique many years ago, back in 1988, and I finally decided to show
it in public (all rights reserved).
In brief, a Magic Square is a n
x
n square grid (where n is
the number of cells on each side) filled with distinct positive integers in the
range 1,2...,n2 such that each cell contains a
different integer and the sum of the integers in each row, column
and diagonal is equal.
An associative magic square is a magic square with a
further property that every number added to the number equidistant, in a
straight line, from the center gives n2 + 1. They are also
called symmetric magic squares. All associated magic square is
self-complementary magic squares as well. (Wikipedia)
To create any odd-order
associative magic square
quickly and hassle-free, we just need to make
two simple passes, that I describe as table
transformations (shifts). The following three tables are depicting the
creation of a 31x31 magic square.
1) We first get the full table filled with
all numbers from 1 to n2 as we go (1st table below showing the cells shifting in green color). Then we make a left
shift of all rows, skipping the middle one, starting with moving one
number (cell) in the first row while moving an extra more number
(cell) in each next row to
n-1 numbers in the last (nth )
row.
2) The second action is similar to the 1st,
but instead of shifting cells in rows, we now shift cells in columns. It
starts with moving one number (cell) upwards from the left side while
moving an extra more number (cell) in each next column to
n-1
numbers in the last (nth ) column, skipping the middle column
this time. That is the 2nd table below, showing the
cells shifting in blue color)
That’s it. A magic square is ready.
That is the 3rd table below, with light and dark grey cells
and yellow diagonals.
1. Initial table with all the numbers from 1
to
n2
in sequence (The green arrow shows the direction of the cell shift
that will follow and the green cells are the ones that will shift.)
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | ||
1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | |
2 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | |
3 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | |
4 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | |
5 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | |
6 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | |
7 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | |
8 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | |
9 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | |
10 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | |
11 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | |
12 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | |
13 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | |
14 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | |
15 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | |
16 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | |
17 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | |
18 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | |
19 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | |
20 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | |
21 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | |
22 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | |
23 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | |
24 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | |
25 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | |
26 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | |
27 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | |
28 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | |
29 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | |
30 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | |
31 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 |
2. First
transformation (primary cell shift). This table is the result of the
shift depicted in green color above. (The
blue arrow shows the direction of the 2nd
and final cell shift and the blue cells are the ones that will shift.)
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | ||
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 1 | |
2 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 32 | 33 | |
3 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 63 | 64 | 65 | |
4 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 94 | 95 | 96 | 97 | |
5 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 125 | 126 | 127 | 128 | 129 | |
6 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 156 | 157 | 158 | 159 | 160 | 161 | |
7 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | |
8 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | |
9 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | |
10 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | |
11 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | |
12 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | |
13 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | |
14 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | |
15 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | |
16 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | |
17 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | |
18 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | |
19 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | |
20 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | |
21 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | |
22 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | |
23 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | |
24 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | |
25 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | |
26 | 801 | 802 | 803 | 804 | 805 | 806 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | |
27 | 833 | 834 | 835 | 836 | 837 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | |
28 | 865 | 866 | 867 | 868 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | |
29 | 897 | 898 | 899 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | |
30 | 929 | 930 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | |
31 | 961 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 |
3.
Final transformation
(secondary cell shift) that gives the Magic Square.
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | ||
1 | 34 | 67 | 100 | 133 | 166 | 199 | 232 | 265 | 298 | 331 | 364 | 397 | 430 | 463 | 480 | 17 | 498 | 531 | 564 | 597 | 630 | 663 | 696 | 729 | 762 | 795 | 828 | 861 | 894 | 927 | 960 | |
2 | 66 | 99 | 132 | 165 | 198 | 231 | 264 | 297 | 330 | 363 | 396 | 429 | 462 | 479 | 527 | 49 | 530 | 563 | 596 | 629 | 662 | 695 | 728 | 761 | 794 | 827 | 860 | 893 | 926 | 959 | 1 | |
3 | 98 | 131 | 164 | 197 | 230 | 263 | 296 | 329 | 362 | 395 | 428 | 461 | 478 | 526 | 528 | 81 | 562 | 595 | 628 | 661 | 694 | 727 | 760 | 793 | 826 | 859 | 892 | 925 | 958 | 31 | 33 | |
4 | 130 | 163 | 196 | 229 | 262 | 295 | 328 | 361 | 394 | 427 | 460 | 477 | 525 | 558 | 560 | 113 | 594 | 627 | 660 | 693 | 726 | 759 | 792 | 825 | 858 | 891 | 924 | 957 | 30 | 32 | 65 | |
5 | 162 | 195 | 228 | 261 | 294 | 327 | 360 | 393 | 426 | 459 | 476 | 524 | 557 | 559 | 592 | 145 | 626 | 659 | 692 | 725 | 758 | 791 | 824 | 857 | 890 | 923 | 956 | 29 | 62 | 64 | 97 | |
6 | 194 | 227 | 260 | 293 | 326 | 359 | 392 | 425 | 458 | 475 | 523 | 556 | 589 | 591 | 624 | 177 | 658 | 691 | 724 | 757 | 790 | 823 | 856 | 889 | 922 | 955 | 28 | 61 | 63 | 96 | 129 | |
7 | 226 | 259 | 292 | 325 | 358 | 391 | 424 | 457 | 474 | 522 | 555 | 588 | 590 | 623 | 656 | 209 | 690 | 723 | 756 | 789 | 822 | 855 | 888 | 921 | 954 | 27 | 60 | 93 | 95 | 128 | 161 | |
8 | 258 | 291 | 324 | 357 | 390 | 423 | 456 | 473 | 521 | 554 | 587 | 620 | 622 | 655 | 688 | 241 | 722 | 755 | 788 | 821 | 854 | 887 | 920 | 953 | 26 | 59 | 92 | 94 | 127 | 160 | 193 | |
9 | 290 | 323 | 356 | 389 | 422 | 455 | 472 | 520 | 553 | 586 | 619 | 621 | 654 | 687 | 720 | 273 | 754 | 787 | 820 | 853 | 886 | 919 | 952 | 25 | 58 | 91 | 124 | 126 | 159 | 192 | 225 | |
10 | 322 | 355 | 388 | 421 | 454 | 471 | 519 | 552 | 585 | 618 | 651 | 653 | 686 | 719 | 752 | 305 | 786 | 819 | 852 | 885 | 918 | 951 | 24 | 57 | 90 | 123 | 125 | 158 | 191 | 224 | 257 | |
11 | 354 | 387 | 420 | 453 | 470 | 518 | 551 | 584 | 617 | 650 | 652 | 685 | 718 | 751 | 784 | 337 | 818 | 851 | 884 | 917 | 950 | 23 | 56 | 89 | 122 | 155 | 157 | 190 | 223 | 256 | 289 | |
12 | 386 | 419 | 452 | 469 | 517 | 550 | 583 | 616 | 649 | 682 | 684 | 717 | 750 | 783 | 816 | 369 | 850 | 883 | 916 | 949 | 22 | 55 | 88 | 121 | 154 | 156 | 189 | 222 | 255 | 288 | 321 | |
13 | 418 | 451 | 468 | 516 | 549 | 582 | 615 | 648 | 681 | 683 | 716 | 749 | 782 | 815 | 848 | 401 | 882 | 915 | 948 | 21 | 54 | 87 | 120 | 153 | 186 | 188 | 221 | 254 | 287 | 320 | 353 | |
14 | 450 | 467 | 515 | 548 | 581 | 614 | 647 | 680 | 713 | 715 | 748 | 781 | 814 | 847 | 880 | 433 | 914 | 947 | 20 | 53 | 86 | 119 | 152 | 185 | 187 | 220 | 253 | 286 | 319 | 352 | 385 | |
15 | 466 | 514 | 547 | 580 | 613 | 646 | 679 | 712 | 714 | 747 | 780 | 813 | 846 | 879 | 912 | 465 | 946 | 19 | 52 | 85 | 118 | 151 | 184 | 217 | 219 | 252 | 285 | 318 | 351 | 384 | 417 | |
16 | 513 | 546 | 579 | 612 | 645 | 678 | 711 | 744 | 746 | 779 | 812 | 845 | 878 | 911 | 944 | 481 | 18 | 51 | 84 | 117 | 150 | 183 | 216 | 218 | 251 | 284 | 317 | 350 | 383 | 416 | 449 | |
17 | 545 | 578 | 611 | 644 | 677 | 710 | 743 | 745 | 778 | 811 | 844 | 877 | 910 | 943 | 16 | 497 | 50 | 83 | 116 | 149 | 182 | 215 | 248 | 250 | 283 | 316 | 349 | 382 | 415 | 448 | 496 | |
18 | 577 | 610 | 643 | 676 | 709 | 742 | 775 | 777 | 810 | 843 | 876 | 909 | 942 | 15 | 48 | 529 | 82 | 115 | 148 | 181 | 214 | 247 | 249 | 282 | 315 | 348 | 381 | 414 | 447 | 495 | 512 | |
19 | 609 | 642 | 675 | 708 | 741 | 774 | 776 | 809 | 842 | 875 | 908 | 941 | 14 | 47 | 80 | 561 | 114 | 147 | 180 | 213 | 246 | 279 | 281 | 314 | 347 | 380 | 413 | 446 | 494 | 511 | 544 | |
20 | 641 | 674 | 707 | 740 | 773 | 806 | 808 | 841 | 874 | 907 | 940 | 13 | 46 | 79 | 112 | 593 | 146 | 179 | 212 | 245 | 278 | 280 | 313 | 346 | 379 | 412 | 445 | 493 | 510 | 543 | 576 | |
21 | 673 | 706 | 739 | 772 | 805 | 807 | 840 | 873 | 906 | 939 | 12 | 45 | 78 | 111 | 144 | 625 | 178 | 211 | 244 | 277 | 310 | 312 | 345 | 378 | 411 | 444 | 492 | 509 | 542 | 575 | 608 | |
22 | 705 | 738 | 771 | 804 | 837 | 839 | 872 | 905 | 938 | 11 | 44 | 77 | 110 | 143 | 176 | 657 | 210 | 243 | 276 | 309 | 311 | 344 | 377 | 410 | 443 | 491 | 508 | 541 | 574 | 607 | 640 | |
23 | 737 | 770 | 803 | 836 | 838 | 871 | 904 | 937 | 10 | 43 | 76 | 109 | 142 | 175 | 208 | 689 | 242 | 275 | 308 | 341 | 343 | 376 | 409 | 442 | 490 | 507 | 540 | 573 | 606 | 639 | 672 | |
24 | 769 | 802 | 835 | 868 | 870 | 903 | 936 | 9 | 42 | 75 | 108 | 141 | 174 | 207 | 240 | 721 | 274 | 307 | 340 | 342 | 375 | 408 | 441 | 489 | 506 | 539 | 572 | 605 | 638 | 671 | 704 | |
25 | 801 | 834 | 867 | 869 | 902 | 935 | 8 | 41 | 74 | 107 | 140 | 173 | 206 | 239 | 272 | 753 | 306 | 339 | 372 | 374 | 407 | 440 | 488 | 505 | 538 | 571 | 604 | 637 | 670 | 703 | 736 | |
26 | 833 | 866 | 899 | 901 | 934 | 7 | 40 | 73 | 106 | 139 | 172 | 205 | 238 | 271 | 304 | 785 | 338 | 371 | 373 | 406 | 439 | 487 | 504 | 537 | 570 | 603 | 636 | 669 | 702 | 735 | 768 | |
27 | 865 | 898 | 900 | 933 | 6 | 39 | 72 | 105 | 138 | 171 | 204 | 237 | 270 | 303 | 336 | 817 | 370 | 403 | 405 | 438 | 486 | 503 | 536 | 569 | 602 | 635 | 668 | 701 | 734 | 767 | 800 | |
28 | 897 | 930 | 932 | 5 | 38 | 71 | 104 | 137 | 170 | 203 | 236 | 269 | 302 | 335 | 368 | 849 | 402 | 404 | 437 | 485 | 502 | 535 | 568 | 601 | 634 | 667 | 700 | 733 | 766 | 799 | 832 | |
29 | 929 | 931 | 4 | 37 | 70 | 103 | 136 | 169 | 202 | 235 | 268 | 301 | 334 | 367 | 400 | 881 | 434 | 436 | 484 | 501 | 534 | 567 | 600 | 633 | 666 | 699 | 732 | 765 | 798 | 831 | 864 | |
30 | 961 | 3 | 36 | 69 | 102 | 135 | 168 | 201 | 234 | 267 | 300 | 333 | 366 | 399 | 432 | 913 | 435 | 483 | 500 | 533 | 566 | 599 | 632 | 665 | 698 | 731 | 764 | 797 | 830 | 863 | 896 | |
31 | 2 | 35 | 68 | 101 | 134 | 167 | 200 | 233 | 266 | 299 | 332 | 365 | 398 | 431 | 464 | 945 | 482 | 499 | 532 | 565 | 598 | 631 | 664 | 697 | 730 | 763 | 796 | 829 | 862 | 895 | 928 |
An
alternative
way (based on the above shift pattern) is to create a magic
square by performing the cell shifting in opposite directions for each
half of the table, always skipping the middle row or column.
Initial square with numbers 1 -
n2 in
sequence
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 |
36 | 37 | 38 | 39 | 40 | 41 | 42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 |
After the first pass. Notice how each column is equal to
Σ
|
2 | 3 | 4 | 5 | 6 | 7 | 1 | |
10 | 11 | 12 | 13 | 14 | 8 | 9 | ||
18 | 19 | 20 | 21 | 15 | 16 | 17 | ||
22 | 23 | 24 | 25 | 26 | 27 | 28 | ||
33 | 34 | 35 | 29 | 30 | 31 | 32 | ||
41 | 42 | 36 | 37 | 38 | 39 | 40 | ||
49 | 43 | 44 | 45 | 46 | 47 | 48 |
Second pass completed and now each row is also equal to Σ. The Magic Square is ready
10 | 19 | 24 | 5 | 30 | 39 | 48 |
18 | 23 | 35 | 13 | 38 | 47 | 1 |
22 | 34 | 36 | 21 | 46 | 7 | 9 |
33 | 42 | 44 | 25 | 6 | 8 | 17 |
41 | 43 | 4 | 29 | 14 | 16 | 28 |
49 | 3 | 12 | 37 | 15 | 27 | 32 |
2 | 11 | 20 | 45 | 26 | 31 | 40 |
Some Notes
Below are some simple notes to help the
reader understand what is happening to the sums of rows and columns of the
initial (1) table
n x n,
and how each pass (series of shifts) affects them, and leads to the construction
of a symmetrical magic square.
n
= square side size (magic square is
n x n
in size)
M
=
(n2+1)/2
(middle number, in the center)
Σ
=
Mn
(Sum of
each row, column, diagonal of the magic square)
r
= the number of rows or columns away from the
middle.
As we create the initial square (1) with all the numbers from 1 to
n2
in sequence, we notice the ‘weight’ difference in each row and column, compared
to the middle row and column accordingly. For columns, going left from the
middle one, the column’s sum is Σ
- rn. For columns going to the
right from the middle one, the sum is
Σ + rn. For rows,
going up from the middle row, the sum is
Σ - (rn2).
For rows, going down from the middle row, the sum is
Σ + (rn2).
The first pass, shifting cells in rows to the left, starting with one cell (1st
top left corner) and incrementing one more cell in every next row, skipping the
middle one, gives us a square (2) where all the row sums are equal to
Σ. Notice how the
left row has gained + 1 to the first cell on the top, adding one extra in every
next cell going to the last cell on the bottom, skipping the middle one. Each
next row is following a decremental pattern of gains, and they all affect the
row sums in a way that compensates the initial (1) sums to equalize with the
middle row.
In a similar fashion, we observe the same behavior in column sums. While they
remain as detailed in the first paragraph above, in squares
(1) and (2), when we
perform the equivalent cell shifting in columns as we previously did in rows, we
notice how the column sums are compensated and become equal to
Σ.
Below we can see:
On the left side, the squares with each cell value in relation to
n.
On the right side, the square progress with
actual values. Square (3) is the final and magic one.
In the green-colored cells, the sums of each
row and column. The diagonals are always equal to
Σ.
In the blue-colored cells, are the initial
middle row and column cells, and their location throughout the passes.
Σ | 175 | Σ | ||||||||||||||||||
n-6 | n-5 | n-4 | n-3 | n-2 | n-1 | n | Σ-(3n2) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 28 | Σ-(3n2) | ||||
n+1 | n+2 | n+3 | n+4 | n+5 | n+6 | n+7 | Σ-(2n2) | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 77 | Σ-(2n2) | ||||
n+8 | n+9 | n+10 | n+11 | n+12 | n+13 | n+14 | Σ-(1n2) | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 126 | Σ-(1n2) | ||||
n+15 | n+16 | n+17 | n+18 | n+19 | n+20 | n+21 | Σ | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 175 | Σ | ||||
n+22 | n+23 | n+24 | n+25 | n+26 | n+27 | n+28 | Σ+(1n2) | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 224 | Σ+(1n2) | ||||
n+29 | n+30 | n+31 | n+32 | n+33 | n+34 | n+35 | Σ+(2n2) | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 273 | Σ+(2n2) | ||||
n+36 | n+37 | n+38 | n+39 | n+40 | n+41 | n+42 | Σ+(3n2) | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 322 | Σ+(3n2) | ||||
Σ | 175 | Σ | ||||||||||||||||||
154 | 161 | 168 | 175 | 182 | 189 | 196 | ||||||||||||||
Σ-(3n) | Σ-(2n) | Σ-(1n) | Σ | Σ+(1n) | Σ+(2n) | Σ+(3n) | Σ-(3n) | Σ-(2n) | Σ-(1n) | Σ | Σ+(1n) | Σ+(2n) | Σ+(3n) | |||||||
Σ | 175 | Σ | ||||||||||||||||||
n-5 | n-4 | n-3 | n-2 | n-1 | n | n-6 | Σ-(3n2) | 2 | 3 | 4 | 5 | 6 | 7 | 1 | 28 | Σ-(3n2) | ||||
n+3 | n+4 | n+5 | n+6 | n+7 | n+1 | n+2 | Σ-(2n2) | 10 | 11 | 12 | 13 | 14 | 8 | 9 | 77 | Σ-(2n2) | ||||
n+11 | n+12 | n+13 | n+14 | n+8 | n+9 | n+10 | Σ-(1n2) | 18 | 19 | 20 | 21 | 15 | 16 | 17 | 126 | Σ-(1n2) | ||||
n+15 | n+16 | n+17 | n+18 | n+19 | n+20 | n+21 | Σ | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 175 | Σ | ||||
n+26 | n+27 | n+28 | n+22 | n+23 | n+24 | n+25 | Σ+(1n2) | 33 | 34 | 35 | 29 | 30 | 31 | 32 | 224 | Σ+(1n2) | ||||
n+34 | n+35 | n+29 | n+30 | n+31 | n+32 | n+33 | Σ+(2n2) | 41 | 42 | 36 | 37 | 38 | 39 | 40 | 273 | Σ+(2n2) | ||||
n+42 | n+36 | n+37 | n+38 | n+39 | n+40 | n+41 | Σ+(3n2) | 49 | 43 | 44 | 45 | 46 | 47 | 48 | 322 | Σ+(3n2) | ||||
Σ | 175 | Σ | ||||||||||||||||||
175 | 175 | 175 | 175 | 175 | 175 | 175 | ||||||||||||||
Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | |||||||
Σ | 175 | Σ | ||||||||||||||||||
n+3 | n+12 | n+17 | n-2 | n+23 | n+32 | n+41 | Σ | 10 | 19 | 24 | 5 | 30 | 39 | 48 | 175 | Σ | ||||
n+11 | n+16 | n+28 | n+6 | n+31 | n+40 | n-6 | Σ | 18 | 23 | 35 | 13 | 38 | 47 | 1 | 175 | Σ | ||||
n+15 | n+27 | n+29 | n+14 | n+39 | n | n+2 | Σ | 22 | 34 | 36 | 21 | 46 | 7 | 9 | 175 | Σ | ||||
n+26 | n+35 | n+37 | n+18 | n-1 | n+1 | n+10 | Σ | 33 | 42 | 44 | 25 | 6 | 8 | 17 | 175 | Σ | ||||
n+34 | n+36 | n-3 | n+22 | n+7 | n+9 | n+21 | Σ | 41 | 43 | 4 | 29 | 14 | 16 | 28 | 175 | Σ | ||||
n+42 | n-4 | n+5 | n+30 | n+8 | n+20 | n+25 | Σ | 49 | 3 | 12 | 37 | 15 | 27 | 32 | 175 | Σ | ||||
n-5 | n+4 | n+13 | n+38 | n+19 | n+24 | n+33 | Σ | 2 | 11 | 20 | 45 | 26 | 31 | 40 | 175 | Σ | ||||
Σ | 175 | Σ | ||||||||||||||||||
175 | 175 | 175 | 175 | 175 | 175 | 175 | ||||||||||||||
Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ | Σ |
Variations
To get different Magic Squares for the same
odd order, you may swap the actions.
For example, instead of making a Left-shift followed by an
Up-shift, you may try starting with a Right-shift
followed by a Down-shift or another combination. Similarly for
the alternative way shown above, you may swap the left-right
dual-action per pass with right-left and the down-up
with up-down.
Below are the four (4) variations of a 19x19 associative Magic Square.
Each is constructed with the same technique but a different action
sequence. Each cell is color-coded according to its 'weight'.
Permutations
Any Magic Square generated from the above technique, including the four (4) variations, have multiple permutations. The permutations derive from shifting rows or columns symmetrically. You may also reposition the four quarters of any magic square. Furthermore, a resulted permutation from symmetrically moving rows can also generate more permutations from moving columns or quarters and vice versa.
The number of permutations for each variation (we have four possible variations for each odd-order) is given by the equation below
As this technique allows for four (4) different
variations, we have a total of
4xP permutations for every odd-order.
For example, for order 7 we get
4x576=2.304
magic squares.
Some cases are shown below (not exhausted) for a 7x7 Magic Square.
|
|
|
|
|
|
|
|
|
|
|
|
Finally, each Magic Square can be turned anticlockwise (or clockwise if
you prefer) to produce four (4) different perspectives as shown below.
4 | 3 | 8 | 8 | 1 | 6 | |
9 | 5 | 1 | 3 | 5 | 7 | |
2 | 7 | 6 | 4 | 9 | 2 | |
6 | 7 | 2 | 2 | 9 | 4 | |
1 | 5 | 9 | 7 | 5 | 3 | |
8 | 3 | 4 | 6 | 1 | 8 |
You may get another four (4) versions by mirroring the above magic squares. So,
for example, the 3x3 magic square can have eight (8) different solutions.
The mirroring can work for any magic square.
Please visit my
YouTube short videos, which show all the steps for
5x5 and
7x7 associative Magic Squares.
Magic Squares links
David Pleacher,
https://www.pleacher.com/mp/puzzles/mathpuz/magmenu.html
Harry White,
http://budshaw.ca/Associative.html,
http://budshaw.ca/Download.html
William Walkington,
https://carresmagiques.blogspot.com/,
https://carresmagiques.blogspot.com/p/magic-square-links.html,
Equations for Marios Mamzeris's odd order associative magic squares by William
Walkington
Holger Danielsson,
https://www.magic-squares.info/construction/odd.html,
https://www.magic-squares.info/info/book.html
Bogdan Golunski,
http://www.number-galaxy.eu/
Inder Taneja,
https://inderjtaneja.com/category/magic-squares/
Arie Breedijk,
https://www.magischvierkant.com/
Wikipedia (Associative magic square),
https://en.wikipedia.org/wiki/Associative_magic_square