How to create magic squares

Updated on December 29, 2017
verdict profile image

I have been teaching mathematics in an Australian High School since 1982, and I am a contributing author to many mathematics text books.

Trapped indoors on a rainy day and with nothing interesting to watch on the television, in desperation you may have discovered your child’s puzzle book and come across ‘magic squares’. Unable to complete them, frustration took over and you resolved to choose the lesser of two evils by returning to TV channel surfing until your trigger-finger succumbed to RSI from overuse of the remote control.

Now, however, is a good time to erase that haunting frustration from your memory and astound your friends by mastering the art of creating magic squares.

A magic square is a square array of numbers with the property that the sum of the numbers in each row, column and diagonal is the same, known as the “magic sum”.

The ‘order’ is the number of rows and columns, so a magic square of order 4 means it has 4 rows and 4 columns. If N is the order, then N x N different numbers are used to complete the magic square.

One of the earliest known records is the Lo Shu Square, described in ancient Chinese literature thousands of years ago and is part of Feng Shui astrology. The story goes that an emperor came across a tortoise with markings on its shell that resembled a Magic Square consisting of 3 rows and 3 columns with a magic sum of 15. This magic sum corresponds to the number of days between the new moon and the full moon.

We will first look at how to construct magic squares of odd order, with the smallest possible magic square having order 3. Then we will see how to complete magic squares whose order is divisible by 4.

The method of construction requires an arithmetic sequence of numbers. This means the difference between consecutive terms of the sequence has the same value. The sequence of numbers used can be whole numbers, integers, fractions, decimals or any other number type, as long as the increment/decrement between successive terms remains the same.

Magic Sum

The sum of a Magic Square is given by the formula

How to create a magic square of odd order

The strategy is to fill squares with consecutive numbers by imagining that from your current position on the magic square, you are moving North East.

As an example, let’s construct the Lo Shu Square using the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9.

Step 1. Always place the first number in the middle column of the first row.

Step 2.

To move North East, move one space right and one space up.

If this takes you outside the grid, go vertically all the way down and place the next number there.

Step 3.

Move one space right and one space up.

If you are outside the grid, go all the way to the left and place the next number there.

Step 4.

Move one space right and one space up.

If the square is occupied, place the next number in the square immediately underneath.

Step 5

Move one space right and one space up.

Step 6

Move one space right and one space up.

Step 7

Move one space right and one space up. This situation occurs for this corner only.

Place the next number in the square underneath.

Step 8. Move space right and one space up.

Just like step 3, go all the way to the left and place the next number there.

Step 9.

Move one space right and one space up.

You are outside the grid, so go vertically all the way down.

Follow the method in this order 5 magic square that uses the numbers 2, 4, 6, 8, …, 50.

The magic sum is 130.

How to create a magic square whose order is divisible by 4

The smallest possible even-ordered magic square consists of 4 rows and 4 columns.

Let’s use the numbers 1, 2, 3, 4, …., 16, which give a magic sum of 34.

Two ‘passes’ are required to enter the 64 numbers.

For the 1st pass, start at the top left and sequentially work across to the right and then down, at the same time jumping over any box that lies on one of the two leading diagonals.

For the 2nd pass, start at the bottom right and work to the left and then up.

How to create an 8 x 8 magic square

The method we use to construct a magic square of order 8 is the same as the method used for the 4 x 4.

The only extra consideration is to include leading diagonals of each 4 x 4 ‘sub-square’.

Let’s use the numbers 1, 2, 3, 4, …., 64, which give a magic sum of 260.

Two ‘passes’ are required for the 64 numbers.

There are many intriguing properties of this magic square. For example, the sum of the diagonals of each 2 x 2 square is the same.

Here are several more interesting properties.

(6 + 7) - (2 + 3) = (62 + 63) - (58 + 59)

(41 + 49) - (9 + 17) = (48 + 56) - (16 + 24)

(12 + 13 + 20 + 21) + (44 + 45 + 52 + 53) = (26 + 27 + 34 + 35) + (30 + 31 + 38 + 39)

Magic Squares provide many patterns and number properties that can be explored at a far greater depth than what I have provided in this article. I cover some of these relationships in a video.

Questions & Answers


    0 of 8192 characters used
    Post Comment
    • profile image


      2 years ago

      Thank you! Very good article. I was looking for this info and this page is much more informative than others and the material is well explained and illustrated.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
    ClickscoThis is a data management platform studying reader behavior (Privacy Policy)