Inspired by Project Euler n°28 et 58.
A n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.
For exemple with n=5, the spiral matrix is :
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13In this example, the sum of the numbers on the diagonals is 101.
What is the sum of the numbers on the diagonals in any n by n spiral (n always odd) ?
HINTS: You want the diagonals, not the whole matrix.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers315
Suggested Problems
-
Find the sum of all the numbers of the input vector
56071 Solvers
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
2091 Solvers
-
Project Euler: Problem 4, Palindromic numbers
1310 Solvers
-
Back to basics 8 - Matrix Diagonals
974 Solvers
-
Count letters occurence in text, specific to words with a given length.
208 Solvers
More from this Author43
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Good math problem / Sequences and Series. This problem can be solved as a polynomial