Created
November 28, 2019 02:42
-
-
Save voith/61a567ce2a64c375abe0c0b4e2611170 to your computer and use it in GitHub Desktop.
sum of the numbers on the diagonals in a 1001 by 1001 spiral
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grid_size = 1001 | |
num = grid_size ** 2 | |
sum_diagonals = num | |
for i in range(grid_size - 1, 0, -2): | |
for _ in range(4): | |
num -= i | |
sum_diagonals += num | |
print(sum_diagonals) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment