Unstub

Ring by ringEasy

Diagonals of a Number Spiral

Write 1, 2, 3 and on in a clockwise spiral out from the centre of a size by size square, size odd. Return the sum of the numbers on its two diagonals.

Aim for O(n) time, O(1) spaceInspired by a classic maths puzzle ↗