On this page
Magic squares look like puzzles: fill a grid so that every row, column and diagonal adds to the same number. Your Class 7 maths book now has a section on them, and they make a neat first problem in arithmetic progressions. Six and a half centuries ago an Indian mathematician wrote a whole chapter treating them as serious mathematics. This post covers Narayana Pandita's approach, the formulas behind it, and worked examples you can try in class or at home.
Who was Narayana Pandita?
The MacTutor biography of Narayana says he was the son of Nrsimha and wrote his best-known work, the Ganita Kaumudi, on arithmetic in 1356; little else is known about him. He was strongly influenced by Bhaskara II. His work includes methods for squaring numbers, integer-sided triangles and a way to approximate square roots using the equation Nx² + 1 = y². For √10 he found 19/6, then 721/228, then 227379/8658, which is correct to eight decimal places.
MacTutor notes that the thirteenth chapter of the Ganita Kaumudi deals with number sequences, and the fourteenth, the last, with magic squares and related figures.
How did Narayana classify magic squares?
The historian Parmanand Singh studied this chapter in Narayana's treatment of magic squares, in the Indian Journal of History of Science (1986). Singh calls it "a detailed mathematical treatment of magic squares which is unique in several respects."
Narayana sorted squares of order N (N rows, N columns, N² cells) by the remainder when N is divided by 4:
Samabhadra (doubly even). N divisible by 4, such as 4 x 4 or 8 x 8.
Vishamabhadra (singly even). Remainder 2, such as 6 x 6.
Vishama (odd). Remainder 1 or 3, such as 3 x 3 or 5 x 5.
Each kind needs a different construction method, which is why the classification matters.
Why are magic squares arithmetic series?
According to Singh, Narayana saw the mathematics of magic squares as the mathematics of series. Fill N² cells with the numbers 1, 2, 3, ..., N². Their total is N²(N² + 1)/2. There are N rows, each with the same sum, so the magic sum is:
Magic sum = N(N² + 1)/2
N = 3: 3 x 10 / 2 = 15.
N = 4: 4 x 17 / 2 = 34.
N = 5: 5 x 26 / 2 = 65.
The NCERT Ganita Prakash Grade 7 chapter Number Play reaches the 3 x 3 result the same way: the nine numbers add to 45, and three equal rows must each add to 15. The same chapter shows the Chautisa Yantra from a 10th-century inscription at the Parshvanath Jain temple in Khajuraho, the first recorded 4 x 4 magic square, where every row, column and diagonal adds to 34.
How did he build a square with any total?
Narayana went further than 1 to N². Singh explains his rule: use an arithmetic series with first term a and common difference d instead. For n = N² terms, the total is S = na + sd, where s is the sum of the first n - 1 natural numbers. Choose S and N, and you get an equation in a and d that you solve in whole numbers.
Singh gives Narayana's examples. With S = 400 and n = 16 (a 4 x 4 square), s = 1 + 2 + ... + 15 = 120, so 400 = 16a + 120d, which is 2a = 50 - 15d. Then d = 0 gives a = 25; d = 2 gives a = 10; d = 4 gives a = -5. With S = 180 and n = 9, s = 36 and a = 20 - 4d, so d = 1 gives a = 16.
Worked example: a 4 x 4 square with magic sum 100
Take Narayana's solution a = 10, d = 2. The 16 numbers are 10, 12, 14, ..., 40.
Check the total. S = 16 x 10 + 120 x 2 = 160 + 240 = 400. Four rows, so each sums to 400/4 = 100.
Use a known pattern. Start from the Chautisa Yantra, whose rows are 7 12 1 14 / 2 13 8 11 / 16 3 10 5 / 9 6 15 4.
Replace each entry k by 10 + 2(k - 1). So 1 becomes 10, 7 becomes 22, 16 becomes 40. The first row becomes 22, 32, 10, 36.
Check a row. 22 + 32 + 10 + 36 = 100. Each row of the original has four entries adding to 34, so each new row adds to 4 x 10 + 2 x (34 - 4) = 40 + 60 = 100. The same argument works for every column and diagonal.
Worked example: a 3 x 3 square with magic sum 60
The Ganita Prakash chapter asks you to create a magic square whose magic sum is 60. Use Narayana's second example, a = 16, d = 1: the numbers 16 to 24.
Start from the 1 to 9 square 2 7 6 / 9 5 1 / 4 3 8, which has magic sum 15.
Add 15 to every entry. Rows become 17 22 21 / 24 20 16 / 19 18 23.
Check. 17 + 22 + 21 = 60, and each row, column and diagonal rises by 3 x 15 = 45, so 15 + 45 = 60.
Which mistakes should you watch for?
Using N² instead of N in the magic sum. The total of all cells is divided by the number of rows, N, not by the number of cells.
Forgetting the diagonals. A grid with equal rows and columns is not magic unless both diagonals match too.
Changing the pattern when you shift numbers. Adding a constant or multiplying by a constant keeps a square magic. Swapping entries usually does not.
For the series side of this, see our guide to sequences and series for JEE. Mahavira's earlier counting rules are in our post on the Ganita Sara Sangraha.
What can a student take from Narayana's way of working?
Find the structure under the puzzle. He saw magic squares as arithmetic series, and that made them solvable.
Generalise. Not just 1 to N², but any first term and any difference.
Classify before you solve. Odd, singly even and doubly even squares need different methods. Sorting first saves wasted effort.
If the jump from a number pattern to a general formula feels hard, Fermi's AI tutor can work out what you already know and build a plan for the session, so you start from the right step.
Try it now: use S = na + sd to build a 3 x 3 magic square with magic sum 33, then check every row, column and diagonal.



