diff --git a/src/Python/Problems001-050/Problem028.py b/src/Python/Problems001-050/Problem028.py index 06afe91..d5ee8e2 100644 --- a/src/Python/Problems001-050/Problem028.py +++ b/src/Python/Problems001-050/Problem028.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Created on 3 Jan 2020 @@ -29,20 +29,20 @@ def compute(): What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way? """ + size = 1001 # Must be odd - ans = 1 # Special case for size 1 + ans = 1 # Special case for size 1 step = 0 - i, cur = 1, 1 - while step < size-1: + i, current = 1, 1 + while step < size - 1: step = i * 2 - for j in range(1, 5): - cur += step - ans += cur + for _ in range(1, 5): + current += step + ans += current i += 1 return ans if __name__ == "__main__": - - print(f"Result for Problem 28: {compute()}") \ No newline at end of file + print(f"Result for Problem 28 is {compute()}")