Nine consecutive integers are placed in the squares of a 3 × 3 grid.
Every column, every row, and every diagonal add up to the same number n and the middle number is 8 .
What is n ?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
As a matter of interest, I think the 9 consecutive integers are 4 through 12. Ed Gray
The "standard" magic square has a 5 in the centre square, so I just added 3 to all the entries in a standard square to create a solution, e.g.,
5 .... 10 ..... 9
12 ... 8 .... 4
7 ..... 6 .... 11
Log in to reply
Wow! This was smart!
I performed an equivalent process in my head, again starting from knowing the numbers that feature in the standard 3 x 3 magic square.
I don't know if this counts as cheating but I took all squares to have the value 8 since this satisfies every condition of the question.
Log in to reply
Clever... But all the integers have to be consecutive... 🤔
Log in to reply
Ahhh... there. I missed that part. Thank you :-)
Looks like this proves that the numbers don't even need to be consecutive. In other words: The rows, columns and diagonals in any 3x3 magic square add up to three times the center square, by extension of the above proof.
Log in to reply
Ah yes, you're right... Looks like this solution doesn't refer to the fact that they are consecutive at all! Which makes me wonder, is there a solution where they aren't consecutive? @Brian Charlesworth
Log in to reply
Sure! A magic square maintains it "magicness" under multiplication, e.g.,
10 ..... 20 ..... 18
24 ..... 16 ..... 8
14 ..... 12 ..... 22
You can then add or subtract a constant from each entry as done in your solution example. In other words, "magicness" is closed under linear transformations.
Log in to reply
@Brian Charlesworth – Ah yes of course... How about not following an arithmetic progression?
Log in to reply
@Geoff Pilling – I think so. We can also add magic squares to one another to get another magic square, so I took a magic square, did a linear transformation followed by a rotation, then added it to the original magic square to get the following non-A.P. example:
17 .... 8 ..... 23
22 .... 16 ... 10
9 ..... 24 .... 15
Looking at this, I've combined three A.P.;s, namely (8,15,22), (9,16,23) and (10,17,24), (or looked at another way (8,9,10), (15,16,17) and (22,23,24)).
Log in to reply
@Brian Charlesworth – There will always be two sets of three A.P's. This is easily shown if you start out with three variables and fill out the square as such:
? a ?
? ? ?
a+b ? a+c
From this, you can deduce the rest of the squares:
a+2b+c a a+b+2c
a+2c a+b+c a+2b
a+b a+2b+2c a+c
The progressions: (a, a+b, a+2b) (a+c, a+c+b, a+c+2b) (a+2c, a+2c+b, a+2c+2b) and the ones with the roles of b and c reversed.
There are exactly 9 solutions (9 different squares) all containing consecutive integers from 4 through 12.
Log in to reply
Are you sure? By my count I get 8. 4 ways to choose the top left corner (must be odd) and once its chosen, 2 ways to choose the bottom left corner. The rest fall right into place. 2 ⋅ 4 = 8
Actually, I did it without assuming any number .Just put a,b,c in the first row then go on to fill the rest boxes to have a fixed sum of "n". In my case the middle row is like this:
8+c-a----------8----------8+a-c
Now simply that directs us to n=24
In order to fill the square with any integer There is infinitely many solution.
However in all such solution we must have n=24
That is very clever!
A square in which every column, row, and diagonal add up to the same number is called a magic square . A well-known 3 × 3 magic square is as follows, where the middle number is 5 and every column, row, and diagonal add up to 1 5 :
Adding 3 to every number in the above magic square would change the middle number to 8 , but now every column, row, and diagonal would add up to 1 5 + 3 ⋅ 3 = 2 4 .
Oh, this is a very neat solution!
But they are not consecutive
Log in to reply
The numbers used are consecutive: 4, 5, 6, 7, 8, 9, 10, 11, 12
When using consecutive integers to bulid the given table n = 3 × m where m is the middle number.
In this case m = 8 then n = 3 × 8 = 2 4
Explained this simple, math becomes beautiful and almost an artform.
easy if you happen to know this rule, but this doesn't explain/prove the rule
Log in to reply
That's not a rule, because the numbers don't need to be consecutive.
Not an explanation of the problem's answer, though.
I'm not satisfied with answers given above. My result is 12. 0 1 2 7 8 6 5 3 4 Consecutive numbers, aren't they?
Here is my brute force method of doing it using python and the Itertools package. Not the most intelegent way to do it... but it is fun programming :D
Prints out: [[ 5 10 9] [12 8 4] [ 7 6 11]]
Consider any magic square with a center of value x. To get every value to be the same, you need to balance the values surrounding it. A good way to go about this is with modular math, which is this in the case of consecutive numbers.
x-1 | x-2 | x+3 |
x+4 | x | x-4 |
x-3 | x+2 | x+1 |
As you can see, the amounts over and under x manage to cancel out in each row, square, and column. You wind up with each row, square and column being 3x. In this case, 24.
That's how I did it too! Nice.
The well known solution for 1 to 9 consecutive digits is 15 and it has 5 at the center instead of 8. Therefore adding 3 to each digits gives us consecutive digits from 4 to 12 with 8 at the center and
Answer=15+3*3=24
Nine consecutive numbers containing 8 can be anything from 1 to 9 to 8 to 16. Since 8 is the middle number of the grid, all the other numbers must include the 8 in a sum of three numbers that has the same total. To make this feasible, the largest number, plus 8, plus the smallest number must give the same sum as the second largest number, plus 8, plus the second smallest number, and so on. From this it follows that 8 must be the middle value number of the sequence, so the sequence must be 4 to 12. Hence 4 + 8 + 12 = 24
I recall that the standard magic square had 5 in the center with the sum n = 15. Add 3 to every square, and we get the numbers 4 through 12 with 8 in the center. Their sum = 72, and id we divide by 3, n = 24. Ed Gray
If we go backward and forward in the grid from 8 , rest of the numbers are 7,6,5, 4 and 9,10,11 and 12 . If we add all of them we have 16*9/2=72 . Hence each row or column or diagonal adds upto 72/3 = 24
Prolog program to derive solution to magic square. just ask (type) ?- g(X).
soma1([A,B,C,D,E,F,G,H,I],N):- N is A + B + C. soma2([A,B,C,D,E,F,G,H,I],N):- N is D + E + F. soma3([A,B,C,D,E,F,G,H,I],N):- N is G + H + I. soma4([A,B,C,D,E,F,G,H,I],N):- N is A + D + G. soma5([A,B,C,D,E,F,G,H,I],N):- N is B + E + H. soma6([A,B,C,D,E,F,G,H,I],N):- N is C + F + I. soma7([A,B,C,D,E,F,G,H,I],N):- N is A + E + I. soma8([A,B,C,D,E,F,G,H,I],N):- N is C + E + G.
lista([4,5,6,7,8,9,10,11,12]). verifica(L,N):- soma1(L,N), soma2(L,N), soma3(L,N), soma4(L,N), soma5(L,N), soma6(L,N), soma7(L,N), soma8(L,N).
go(N):- lista(L), permutation(L,Ls), [A,B,C,D,E,F,G,H,I] = Ls, E = 8, verifica([A,B,C,D,E,F,G,H,I],N), faz([A,B,C,D,E,F,G,H,I]).
faz([A,B,C,D,E,F,G,H,I]):- write([A,B,C]), nl, write([D,E,F]), nl, write([G,H,I]), nl.
The rule for solving magic squares with 1 digit(the digit has to be in the center) is that 3 times the middle digit or n as you have to find.
Problem Loading...
Note Loading...
Set Loading...
If each row adds up to n , then all 9 squares add up to 3 n .
Also, if we add up the four lines that pass through 8 , we get the sum of all squares + 3 additional 8 's, or 3 n + 3 ⋅ 8 . But this also adds up to 4 n , since it is four groups of three that add up to n each.
Therefore 3 n + 3 ⋅ 8 = 4 n , or n = 2 4
Here is one way to do it: