# In a magic square each row, column, and diagonal have the same sum. Check which of the following is a magic square.$5$$-1$$-4$$-5$$-2$$7$$0$$3$$-3$(i)$1$$-10$$0$$-4$$-3$$-2$$-6$$4$$-7$(ii)"

#### Complete Python Prime Pack

9 Courses     2 eBooks

#### Artificial Intelligence & Machine Learning Prime Pack

6 Courses     1 eBooks

#### Java Prime Pack

9 Courses     2 eBooks

To do:

We have to find which of the given square is a magic square.

Solution:

A magic square is an array of numbers where the sum of rows, columns, and diagonal elements are equal.

Let us consider the square (i)

On adding the numbers in each row we get,

1st Row $=5+(-1)+(-4)$

$=5-1-4$

$=5-5$

$=0$

2nd Row $=-5+(-2)+7$

$=-5-2+7$

$=-7+7$

$=0$

3rd Row $=0+3+(-3)$

$=3-3$

$=0$

On adding the numbers in each column we get,

1st Column $=5+(-5)+0$

$=5-5$

$=0$

2nd Column $=(-1)+(-2)+3$

$=-1-2+3$

$=-3+3$

$=0$

3rd Column $=-4+7+(-3)$

$=-4+7-3$

$=-7+7$

$=0$

On adding the numbers of the diagonals we get,

1st Diagonal $=5+(-2)+(-3)$

$=5-2-3$

$=5-5$

$=0$

2nd Diagonal $=-4+(-2)+0$

$=-4-2$

$=-6$

Since, the sum of one of the diagonals is not equal to zero,

So, (i) is not a magic square

Now, let us consider the square (ii)

On adding the numbers in each row we get,

1st Row $=1+(-10)+0$

$=1-10+0$

$=-9$

2nd Row $=(-4)+(-3)+(-2)$

$=-4-3-2$

$=-9$

3rd Row $=(-6)+4+(-7)$

$=-6+4-7$

$=-13+4$

$=-9$

On adding the numbers in each column we get,

1st Column $=1+(-4)+(-6)$

$=1-4-6$

$=1-10$

$=-9$

2nd Column $=(-10)+(-3)+4$

$=-10-3+4$

$=-13+4$

$=-9$

3rd Column $=0+(-2)+(-7)$

$=0-2-7$

$=-9$

On adding the numbers of the diagonals we get,

1st Diagonal $=1+(-3)+(-7)$

$=1 – 3 – 7$

$=1 – 10$

$=-9$

2nd Diagonal $=0+(-3)+(-6)$

$=0 – 3 – 6$

$=-9$

This square box is a magic square because each row, column, and diagonal have the same sum.

Updated on 10-Oct-2022 13:31:00