* Solver for https://projecteuler.net/problem=28 The above problem displays an interesting looking square of numbers (generated by counting up from one in a spiral pattern) and asks us to sum the diagonal for a very large square. In some cases to my detriment, I always try to look for a magical formula that will solve every problem. In this case, that is possible! We need only recognize that the numbers we are asked to sum belong to a sequence: The sequence: {1, 3, 5, 7, 9, 13, 17, 21, 25, 31, 37, 43, 49, 57...} We see that all of the numbers are odd. Further, we see that the first four numbers in the sequence are spaced two numbers apart. The next four numbers are all four numbers apart, then six numbers, then eight, etc. ** Solution My solution is to implement a formula that can generate number /N/ (zero-indexed) in the sequence given the F_N_-1 (in other words, the preceeding number in the sequence. The formula is this: F_n = F_n_-1 + 2 * (((n-1) // 4) + 1) Here is an example of calculating the ninth number in the sequence (25): (zero indexed!) F_8 = F_7 + 2 * ((8-1) // 4) + 1) F_8 = 21 + 2 * (1 + 1) F_8 = 25 And the tenth number: F_9 = F_8 + 2 * ((9-1) // 4) + 1) F_9 = 25 + 2 * (2 + 1) F_9 = 25 + 6 F_9 = 31 The scheme itself looks nicer than the formula.