Magic constant

There are some squares that are called magical. Well, probably everyone knows that the sum of numbers in such squares along horizontals, verticals and main diagonals is the same, that is, equal to the same number, this number-sum is called the magic constant (M n , where n is the size of the square; n> 2). Back in school, I remember the formula for calculating this constant: M n = n * (n 2 + 1) / 2, it was not clear for me where it came from ... here we will try to derive it, maybe someone has already deduced it, maybe also Perhaps in a different way, it doesn’t matter just to write.

Writing again the numbers in squares, once noticed such a thing. If you enter numbers from 1 to n 2 in columns from left to right, you always get a magic constant when adding numbers along any main diagonal, here you can see it:

M 3 :
1 4 7
2 5 8
3 6 9

M 4 :
1 5 9   13
2 6 10 14
3 7 11 15
4 8 12 16

According to the formula:

M 3 = n * (n 2 + 1) / 2 = 3 * (3 * 3 + 1) / 2 = 30/2 = 15
M 4 = n * (n 2 + 1) / 2 = 4 * (4 * 4 + 1) / 2 = 68/2 = 34

On the diagonals (bold above):

M 3 = 1 + 5 + 9 = 15
M 4 = 1 + 6 + 11 + 16 = 34

Unlike the formula, the diagonals are able to give an answer what happens. Consider the numbers on the diagonals:

M 3 = 1 + 5 + 9
M 4 = 1 + 6 + 11 + 16

Rewrite it differently:

M 3 = 1 + (3 + 2) + (3 * 2 + 3)
M 4 = 1 + (4 + 2) + (4 * 2 + 3) + (4 * 3 + 4)

Notice? Now in a general view from n:

M n= 1 + (n + 2) + (n * 2 + 3) + (n * 3 + 4) + (n * 4 + 5) + ... + (n * (n-1) + n) We will

rearrange this (highlighted bold)
M n = 1 + (n + 2 ) + (n * 2 + 3 ) + (n * 3 + 4 ) + (n * 4 + 5 ) + ... + (n * (n-1) + n )

and this (in bold)
M n = 1 + ( n + 2) + ( n * 2 + 3) + ( n * 3 + 4) + ( n * 4 + 5) + ... + ( n * (n-1 ) + n)

and get:

M n = (1 + 2 + 3 + 4 + 5 + ... + n) + (n + n * 2 + n * 3 + n * 4 + ... + n * (n-1) )

put n out of the bracket:

M n = (1 + 2 + 3 + 4 + 5 + ... + n) + n * (1 + 2 + 3 + 4 + ... + (n-1))       [1]

Now we introduce a new designation ,

S n = 1 + 2 + 3 + ... + n                                                                                  [2]
, then
S n-1 = 1 + 2 + 3 + ... + (n-1) = S n - n                                                            [3]

Now we rewrite the formula [1] taking into account the notation [2] and [3], and get:

M n = S n + n * (S n - n)                                                                                  [4]

or so:

M n = Sn * (n + 1) - n 2

                                                    [5]

S n considering that - obviously calculated by the formula S n = n 2 /2 + n / 2 = n * (n + 1) / 2 is substituted in [5] : M n = S n * (n + 1) - n 2 = n * (n + 1) * (n + 1) / 2 - n 2 = n * (n 2 + 2 * n + 1 - 2 * n ) / 2 = n * (n 2 + 1) / 2 M n = n * (n 2 + 1) / 2 CTD












Also popular now: