Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
It can be verified that the sum of the numbers on the diagonals is 101.
What is the sum of the numbers on the main diagonals in a N by N spiral formed in the same way?
Source: Project Euler
I see you are totaling the numbers on that X-shaped area, rather than summing the two totals of the diagonals (i.e., the 1 at the center counts only once).
The members of each successive shell follow a second degree polynomial function; therefore, the totals follow a third degree polynomial
73 81
43 44 45 46 47 48 49
42 21 22 23 24 25 26
41 20 7 8 9 10 27
40 19 6 1 2 11 28
39 18 5 4 3 12 29
38 17 16 15 14 13 30
37 36 35 34 33 32 31
65 57
For a 3 x 3 the total is 25
For a 5 x 5 the total is 101
For a 7 x 7 the total is 261
t = a*n^3 + b*n^2 + c*n + d
25 = 27a + 9b + 3c + d
101 = 125a + 25b + 5c + d
261 = 343a + 49b + 7c + d
537 = 729a + 81b + 9c + d
Using
https://www.symbolab.com/solver/system-of-equations-calculator
to solve, we get:
t = 2*n^3 / 3 + n^2 / 2 + 4*n/3 - 3/2
This checks out when evaluated.
|
Posted by Charlie
on 2016-04-26 10:09:11 |