How to Solve a Magic Square: Formulas & Rules to Use (2024)

Download Article

What makes magic squares special and how to fill them in

Co-authored byHunter Rising

Last Updated: April 13, 2024Fact Checked

Download Article

  • What is a magic square?
  • |
  • Solving a 3 x 3
  • |
  • Solving a 4 x 4
  • |
  • Singly Even Magic Square
  • |
  • Video
  • |

If you’re a fan of math and logic puzzles like Sudoku or Kenken, then trying to solve a magic square is the perfect little challenge to try out. A magic square is a grid of numbers where each row, column, and diagonal add up to the same sum. How you solve your magic square depends on the size of the puzzle, but they each have easy instructions for filling them in. Keep reading and we’ll walk through our solving strategies step by step to finish any odd- or even-numbered magic square.

Things You Should Know

  • A magic square is a square grid of numbers where each row, column, and diagonal add up to the same total.
  • Find the “magic constant” sum of each row, column, and diagonal with How to Solve a Magic Square: Formulas & Rules to Use (3) where n is the number of squares in each row.
  • Use a solving technique based on the size of the magic square and how many boxes are in each row or column.

Section 1 of 4:

What is a magic square?

Download Article

  1. Magic squares have rows, columns, and diagonals that total the same sum. Each number in a magic square fits into a cell on a grid. The number of rows or columns determines the order, so an “order 3” magic square is one with a 3 x 3 grid. When you add up the numbers in a column, the value is called the “magic constant,” and all the other columns, rows, and diagonals will add up to that number.[1]

    • A normal magic square has consecutive numbers from 1 to How to Solve a Magic Square: Formulas & Rules to Use (6) (where n equals the order). A normal order 3 magic square with a magic constant of 15 would be:
      8 – 1 – 6
      3 – 5 – 7
      4 – 9 – 2
    • On a non-normal magic square, the lowest number may be higher than 1. A non-normal order 4 magic square with a magic constant of 87 could be:
      21 – 24 – 28 – 14
      27 – 15 – 20 – 25
      16 – 30 – 22 – 19
      23 – 18 – 17 – 29
  2. Advertisem*nt

Section 2 of 4:

3 x 3 or Odd-Numbered Squares

Download Article

  1. 1

    Calculate the magic constant. To find the magic constant (S) for a normal magic square use the formula How to Solve a Magic Square: Formulas & Rules to Use (9) where How to Solve a Magic Square: Formulas & Rules to Use (10) equals the order, or number of rows, in the magic square. So for a 3×3 magic square, the formula would be:[2]

    • S = How to Solve a Magic Square: Formulas & Rules to Use (11)
    • S = How to Solve a Magic Square: Formulas & Rules to Use (12)
    • S = How to Solve a Magic Square: Formulas & Rules to Use (13)
    • S = How to Solve a Magic Square: Formulas & Rules to Use (14)
    • S = 15
    • All rows, columns, and diagonals must add up to 15.
    • Normal magic squares always have the same magic constant. If solving for a non-normal square, add all the numbers together and divide by the number of rows to find the magic constant.
  2. 2

    Place the number 1 in the center box on the top row. The placement is the same for any normal magic square with an odd number of columns or rows. Find the center square in the top row and write down the number 1 to get started.[3]

    • Example: If you have a 3 x 3 magic square, put 1 in the second box in the top row.
    • Example: For a 15 x 15 magic square, put the 1 in the eighth box of the row.
  3. 3

    Follow an up-one, right-one pattern to fill in the remaining numbers. Start at the middle box in the top row where you placed the 1. Move up one row and to the right one column and write in the next number sequentially. Whenever a move takes you above the top row (like the first move will), go to the bottom row instead. If you need to move a square to the right but are already in the rightmost column, move to the leftmost column instead. Continue filling in the square following the pattern until it’s complete.[4]

    • Example: In a normal 3 x 3 square, the 2 goes in the bottom right corner and the 3 goes in the left column in the center row.
    • If the movement takes you to a box that is already occupied, go back to the last box that has been filled in, and place the next number directly below it. For example, when you place the 4 in a 3 x 3 magic square, it fits in the bottom left corner below the 3. Then, following the same up-one, right-one pattern, place the 5 in the center of the puzzle to continue.
  4. Advertisem*nt

Section 3 of 4:

4 x4 or Doubly Even Magic Square

Download Article

  1. 1

    Recognize a doubly even square if the sides are divisible by 4. Count the number of squares in a single row or column of your magic square. If the magic square is an order 4 square or the number is evenly divisible by 4 (8, 12, 16, etc.), then you’re working with a doubly even square.[5]

  2. 2

    Calculate the magic constant. Use the formula How to Solve a Magic Square: Formulas & Rules to Use (20), where How to Solve a Magic Square: Formulas & Rules to Use (21) equals the order, or the number of boxes per row in your magic square. So, for a 4 x 4 square, the magic constant calculation becomes:[6]

    • S = How to Solve a Magic Square: Formulas & Rules to Use (22)
    • S = How to Solve a Magic Square: Formulas & Rules to Use (23)
    • S = How to Solve a Magic Square: Formulas & Rules to Use (24)
    • S = How to Solve a Magic Square: Formulas & Rules to Use (25)
    • S = 34
    • All rows, columns, and diagonals must add up to 34.
  3. 3

    Create Highlights A–D in the corners of the magic square. Form a mini square in each corner that has a length of How to Solve a Magic Square: Formulas & Rules to Use (27) on each side, where How to Solve a Magic Square: Formulas & Rules to Use (28) is the magic square’s order. Start in the top left corner and label the mini squares A, B, C, and D going clockwise around the magic square.[7]

    • In a 4 x 4 square, only mark the 4 corner boxes as your highlights.
    • For an 8 x 8 magic square, the Highlights become 2 x 2 mini squares in the corners.
    • In a 12 x 12 square, each Highlight is a 3 x 3 area.
  4. 4

    Create the Central Highlight. Mark all the boxes in the center of the magic square in a square area of length How to Solve a Magic Square: Formulas & Rules to Use (30), where How to Solve a Magic Square: Formulas & Rules to Use (31) is the magic square’s order. The Central highlight will touch a 1 corner each from Highlights A–D, but it shouldn’t overlap them at all.[8]

    • In a 4 x 4 square, the Central Highlight would be a 2 x 2 area in the center.
    • In an 8 x 8 square, the Central Highlight would be a 4 x 4 area in the center.
  5. 5

    Fill in the highlighted areas of your magic square. Start in the top left corner of your magic square. Place 1 in the top left corner and count the boxes across the top row. If a box is highlighted, fill it in with the number. Work down the entire magic square until all the highlighted areas are filled in. In an order 4 magic square, the boxes and their numbers are:[9]

    • 1 in the top-left box and 4 in the top-right box
    • 6 and 7 in the second and third boxes in Row 2
    • 10 and 11 in the second and third boxes of Row 3
    • 13 in the bottom-left box and 16 in the bottom-right box
  6. 6

    Fill in the rest of the magic square by counting backward. Begin again with the top left box, but skip over all the boxes that you already filled in. Count down from the highest number in the magic square as you work across the row, and add the number to any empty box. Once you finish, your magic square is complete. In a 4x4 magic square, the boxes you fill in are:[10]

    • 15 and 14 in the second and third boxes in Row 1
    • 12 in the leftmost box and 9 in the rightmost box in Row 2
    • 8 in the leftmost box and 5 in the rightmost box in Row 3
    • 3 and 2 in the second and third boxes in Row 4
  7. Advertisem*nt

Section 4 of 4:

Singly Even Magic Square

Download Article

  1. 1

    Check if the square’s sides are divisible by 2, but not 4. Singly even magic squares have an even number of boxes in their rows and columns. If you divide the magic square’s order by 2 and get an odd number as the result, you’re working with a singly even square.[11]

    • The smallest possible singly even magic square is 6 x 6 since 2 x 2 magic squares are impossible to make.
  2. 2

    Calculate the magic constant. Use the formula How to Solve a Magic Square: Formulas & Rules to Use (37), where n equals the magic square’s order, or the number of boxes per side. For a 6 x 6 square, your formula would look like:[12]

    • S = How to Solve a Magic Square: Formulas & Rules to Use (38)
    • S = How to Solve a Magic Square: Formulas & Rules to Use (39)
    • S = How to Solve a Magic Square: Formulas & Rules to Use (40)
    • S = How to Solve a Magic Square: Formulas & Rules to Use (41)
    • S = 111
    • Hence, the magic constant for a 6×6 square is 111 and all rows, columns, and diagonals will add up to this number.
  3. 3

    Divide the magic square into four quadrants of equal size. Divide the magic square’s order by 2 to find out how many boxes each side of the quadrant should be. Draw lines to separate the quadrants and label them A (top left), C (top right), D (bottom left), and B (bottom right).[13]

    • For a 6 x 6 square, each quadrant is 3 x 3 boxes.
  4. 4

    Assign each quadrant a number range. Count the number of boxes in a single quadrant to know how many numbers are in each section. Assign Quadrant A the first quarter of numbers, Quadrant B the second quarter, Quadrant C the third quarter, and Quadrant D the final quarter. That way, you know which numbers are going into specific quadrants without accidentally reusing them.[14]

    • In a 6 x 6 square, Quadrant A contains the numbers 1-9, Quadrant B has 10-18, Quadrant C has 19-27, and Quadrant D ends with 28-36.
  5. 5

    Solve each quadrant using a one-up, one-right pattern. In each quadrant, put the lowest value in the center box in the top row. Move up one row and to the right one column to place your next number. If you go above the top row of the quadrant, then move to the bottom row instead. When you go past the rightmost column, add the number to the leftmost column. If there’s already a number in the next square, put the next number directly below the last one.[15]

  6. 6

    Create Highlights A and D. In Quadrant A, mark all the squares in the top row to the left of the quadrant’s center square. In the second row, skip the first column and highlight the center square and remaining boxes to the left of it. Then, mark the squares in the bottom row that share a column with the boxes in the top row to finish the A highlights. Then, repeat the same process in Quadrant D for the D highlights.[16]

    • In a 6 x 6 square, Highlight A-1 is the top right box, Highlight A-2 is the center box in the middle row, and Highlight A-3 is the bottom right corner of Quadrant A. The D highlights are in the same position in Quadrant D.
    • If you tried to add up your columns, rows, and diagonals right now, the square isn’t considered magic since they don’t add up to the same magic constant yet.
  7. 7

    Swap the positions of Highlights A and D. Simply take the number from one square and swap it with the corresponding box between Quadrant A and Quadrant D. Once you’ve done this, all the rows, columns, and diagonals in a 6 x 6 magic square will add up to the magic constant you calculated.[17]

    • Example: In a 6 x 6 magic square, 8 swaps positions with 35, 5 swaps with 32, and 4 swaps with 31.
  8. 8

    Swap the right columns in B and C for magic squares larger than 6 x 6. Count the highlighted columns in the top row of Quadrant A and subtract 1. Count that number of columns in from the right side of Quadrants B and C and highlight all the squares. Move the values in Quadrant C into the corresponding squares in Quadrant B, and vice-versa to complete your magic square.[18]

    • For a 10 x 10 magic square, only swap the rightmost column in quadrants B and C.
    • For a 14 x 14 magic square, swap the 2 rightmost columns instead.
  9. Advertisem*nt

Community Q&A

Search

Add New Question

  • Question

    How do you solve a 7x7 magic square?

    How to Solve a Magic Square: Formulas & Rules to Use (48)

    wikiHow Staff Editor
    Staff Answer

    This answer was written by one of our trained team of researchers who validated it for accuracy and comprehensiveness.

    How to Solve a Magic Square: Formulas & Rules to Use (49)

    wikiHow Staff Editor

    Staff Answer

    Place the first number of the magic square in the center box of the top row. Then, use an up-one, right-one pattern to add the numbers.

    Thanks! We're glad this was helpful.
    Thank you for your feedback.
    If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission.Support wikiHow

    YesNo

    Not Helpful 0Helpful 5

  • Question

    How do I solve a magic square with no known sum?

    How to Solve a Magic Square: Formulas & Rules to Use (50)

    wikiHow Staff Editor
    Staff Answer

    This answer was written by one of our trained team of researchers who validated it for accuracy and comprehensiveness.

    How to Solve a Magic Square: Formulas & Rules to Use (51)

    wikiHow Staff Editor

    Staff Answer

    Magic squares with numbers that start at 1 and are in consecutive order always have the same sum. A 3 x 3 magic square always has the sum of 15 and a 4 x 4 has a sum of 34.

    Thanks! We're glad this was helpful.
    Thank you for your feedback.
    If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission.Support wikiHow

    YesNo

    Not Helpful 2Helpful 1

  • Question

    How do you make a 4 x 4 magic square using only 0-9 digits?

    How to Solve a Magic Square: Formulas & Rules to Use (52)

    wikiHow Staff Editor
    Staff Answer

    This answer was written by one of our trained team of researchers who validated it for accuracy and comprehensiveness.

    How to Solve a Magic Square: Formulas & Rules to Use (53)

    wikiHow Staff Editor

    Staff Answer

    Typically, you can't repeat digits in a magic square so making a 4 x 4 with the digits 0-9 isn't possible unless you repeat them.

    Thanks! We're glad this was helpful.
    Thank you for your feedback.
    If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission.Support wikiHow

    YesNo

    Not Helpful 0Helpful 1

See more answers

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Submit

      Advertisem*nt

      Video

      Submit a Tip

      All tip submissions are carefully reviewed before being published

      Submit

      Thanks for submitting a tip for review!

      You Might Also Like

      How toCalculate a Diagonal of a SquareHow toSolve for X
      How toSolve a SudokuHow toSolve Hard Sudoku PuzzlesHow toSolve Sudoku when StuckHow toDo Sudoku FastHow to Add One Line to Make 200: Answer RevealedSudoku Techniques: How to Solve a 3x3 Sudoku PuzzleHow toCreate a SudokuHow toSolve 8 PuzzleHow toSolve KakuroHow toSolve a 15 PuzzleHow toPlay Sudoku for KidsHow toSolve Logic Puzzles

      Advertisem*nt

      More References (9)

      About This Article

      How to Solve a Magic Square: Formulas & Rules to Use (67)

      Co-authored by:

      Hunter Rising

      wikiHow Staff Writer

      This article was co-authored by wikiHow staff writer, Hunter Rising. Hunter Rising is a wikiHow Staff Writer based in Los Angeles. He has more than three years of experience writing for and working with wikiHow. Hunter holds a BFA in Entertainment Design from the University of Wisconsin - Stout and a Minor in English Writing. This article has been viewed 1,112,275 times.

      19 votes - 70%

      Co-authors: 51

      Updated: April 13, 2024

      Views:1,112,275

      Categories: Featured Articles | Mathematical Puzzles

      Article SummaryX

      To solve an odd-numbered magic square, start by using the formula n[(n^2+1)/2] to calculate the magic constant, or the number that all rows, columns, and diagonals must add up to. For example, in a 3 by 3 square where n=3, the magic constant is 15. Next, start your square by placing the number 1 in the center box of the top row. Then, arrange the rest of the numbers sequentially by moving up 1 row, then 1 column to the right. To learn more, including how to solve singly even magic squares and doubly even magic squares, read on.

      Did this summary help you?

      In other languages

      Spanish

      German

      Portuguese

      Russian

      French

      Indonesian

      Dutch

      Turkish

      • Print
      • Send fan mail to authors

      Thanks to all authors for creating a page that has been read 1,112,275 times.

      Did this article help you?

      Advertisem*nt

      How to Solve a Magic Square: Formulas & Rules to Use (2024)

      FAQs

      How to Solve a Magic Square: Formulas & Rules to Use? ›

      To calculate the magic constant

      magic constant
      The magic constant or magic sum of a magic square is the sum of numbers in any row, column, or diagonal of the magic square. For example, the magic square shown below has a magic constant of 15.
      https://en.wikipedia.org › wiki › Magic_constant
      , add all nine numbers used in the magic square and divide by the number of rows. In our example, add 1+2+3+4+5+6+7+8+9 = 45, then divide by 3. The magic constant for this example is 15, as 45 / 3 = 15.

      What is the formula for solving magic squares? ›

      How to Solve Magic square. As mentioned above, the formula of the magic square sum is n(n2 + 1)/2. For a magic square of order 3, we need to substitute n = 3 to know the magic sum so that we can easily form the magic square 3×3.

      What are the rules for magic squares? ›

      For a magic square all the n numbers in a column, row and diagonal add up to the same constant. A magic square takes in the integers from 1 to n^2. The fixed sum of the numbers in a row, column, and diagonal is called a magic constant or a magic sum. This number is represented by M.

      What is the trick to solve magic square? ›

      Solve each quadrant using a one-up, one-right pattern.

      If you go above the top row of the quadrant, then move to the bottom row instead. When you go past the rightmost column, add the number to the leftmost column. If there's already a number in the next square, put the next number directly below the last one.

      What is the rule for the 5x5 magic square? ›

      A 5 x 5 magic square would have a sum of 65 (lowest number plus highest number; halve it; multiply by row length; that's 1 + 25 = 26; 26/2 = 13; 13 x 5 = 65).

      What is the algorithm for magic square? ›

      A magic square A = [ a i j ] of degree is called symmetrical if the sum of each pair of two opposite entries a i j , a i j ∗ = a n + 1 − i , n + 1 − j with respect to the center is 2 ‖ A ‖ n , that is, a i j + a n + 1 − i , n + 1 − j = 2 ‖ A ‖ n .

      What is the formula for calculating squares? ›

      What Is the Squaring Formula in Math? In math, the square formula calculates the square of any number, square of a = a2 = a × a, such as the square of 5 is 5 × 5 = 25. We can clearly see that the square and the square root of any number are inverse operations.

      What is the magic square format? ›

      A magic square of order n is an arrangement of n2 numbers, usually distinct integers, in a square, such that the n numbers in all rows, all columns, and both diagonals sum to the same constant. A magic square contains the integers from 1 to n2. the magic constants are: 15, 34, 65, 111, 175, 260, ...

      What are the conditions for magic square? ›

      If a square is divided into n2 smaller squares and one of the integers from 1 to n2 is written in each of the smaller squares (using each number only once) in such a way that the sum of the integers in any row, column, or main diagonal is always the same, the result is called a magic square of order n.

      What is the formula for the birthday magic square? ›

      Ramanujan created the following birthday magic square from his date of birth (in DD MM YYYY format) where all four rows, four columns and two diagonals sum up to 139. e.g. sum of all rows equals to 139. 22 + 87 + 19 + 11 =139; 17 + 09 + 24 + 89 =139; That seems like magic and hence the name — magic square.

      How many solutions does a magic square have? ›

      It is known that there are 880 distinct solutions for a 4x4, or order 4 magic square, containing the numbers 1-16, magic total 34.

      Is there a formula for magic squares? ›

      To calculate the magic constant, add all nine numbers used in the magic square and divide by the number of rows. In our example, add 1+2+3+4+5+6+7+8+9 = 45, then divide by 3. The magic constant for this example is 15, as 45 / 3 = 15.

      What are the rules for a magic square? ›

      Like most of my favorite math games and activities, the rules can be summed up in a sentence or two. Take a 3x3 box like the one at right and fill it with the digits 1-9, using each digit only once. The Magic Square is complete when all rows, all columns, and both diagonals add up to the same number. That's it!

      How many magic square combinations are there? ›

      Note that with a 3x3 magic square, there are only 9! = 362880 possibilities, so it's quite easy to try them all. With 4x4, there are 16! = 21 trillion possibilities so it's quite hard to try them all.

      What is the formula for the magic constant? ›

      The magic constant of a magic square of nth order can be found by dividing the sum of 1 to n2 by n; namely, the magic constant = n (n2+1)/2. Magic squares are called “magic squares” in English.

      What is the genetic algorithm for magic square? ›

      Genetic Algorithm

      The magic square is encoded using an array of n*n bitvectors each with a size of ceil(ld(n*n)). A problem-specific crossover-operator is used which could be refered to as permutation operator. The operator is unary. That is each of the two crossover partners is handled individually.

      How to solve magic square 2x2? ›

      First, find the value of the entire square. 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = 45. R1 + R2 + R3 = 45. Therefore the sum of each row is 45/3 = 15.

      References

      Top Articles
      Latest Posts
      Article information

      Author: Lidia Grady

      Last Updated:

      Views: 6294

      Rating: 4.4 / 5 (45 voted)

      Reviews: 92% of readers found this page helpful

      Author information

      Name: Lidia Grady

      Birthday: 1992-01-22

      Address: Suite 493 356 Dale Fall, New Wanda, RI 52485

      Phone: +29914464387516

      Job: Customer Engineer

      Hobby: Cryptography, Writing, Dowsing, Stand-up comedy, Calligraphy, Web surfing, Ghost hunting

      Introduction: My name is Lidia Grady, I am a thankful, fine, glamorous, lucky, lively, pleasant, shiny person who loves writing and wants to share my knowledge and understanding with you.