Project Euler

Project Euler Problem 28

steloflute 2012. 6. 9. 00:01

Problem 28

11 October 2002

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 diagonals in a 1001 by 1001 spiral formed in the same way?


Answer:
669171001

 

 

Pencil & Paper

 

5*5-4                   5*5
      3*3-2       3*3
              1
      3*3-4       3*3-6
5*5-8                   5*5-12

 

1+sigma(k=1,500)(4(2k+1)^2-6(2k))





'Project Euler' 카테고리의 다른 글

Project Euler Problem 30  (0) 2012.06.09
Project Euler Problem 29  (0) 2012.06.09
Project Euler Problem 27  (0) 2012.06.08
Project Euler Problem 26  (0) 2012.06.08
Project Euler Problem 25  (0) 2012.06.08