--- id: 5900f3881000cf542c50fe9b challengeType: 5 title: 'Problem 28: Number spiral diagonals' videoUrl: '' localeTitle: '' --- ## Description
Começando pelo número 1 e indo para a direita no sentido horário, forma-se uma espiral de 5 por 5 como segue: 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 Pode-se verificar que a soma dos números nas diagonais é 101. Qual é a soma dos números nas diagonais em uma por n espiral formada da mesma maneira?
## Instructions
## Tests
```yml tests: - text: spiralDiagonals(101) deve retornar 692101. testString: 'assert(spiralDiagonals(101) == 692101, "spiralDiagonals(101) should return 692101.");' - text: spiralDiagonals(303) deve retornar 18591725. testString: 'assert(spiralDiagonals(303) == 18591725, "spiralDiagonals(303) should return 18591725.");' - text: spiralDiagonals(505) deve retornar 85986601. testString: 'assert(spiralDiagonals(505) == 85986601, "spiralDiagonals(505) should return 85986601.");' - text: spiralDiagonals(1001) deve retornar 669171001. testString: 'assert(spiralDiagonals(1001) == 669171001, "spiralDiagonals(1001) should return 669171001.");' ```
## Challenge Seed
```js function spiralDiagonals(n) { // Good luck! return n; } spiralDiagonals(1001); ```
## Solution
```js // solution required ```