**Not a member of Pastebin yet?**

**, it unlocks many cool features!**

__Sign Up__- https://projecteuler.net/problem=28
- The series to get the result has this pattern:
- 1 + [3 + 5 + 7 + 9] + [13 + 17 + 21 + 25 ] + [31 + 37 + 43 + 49] + [ 56 ...
- There's always a quertet of four summands.
- How many you skip between the 4 summands (difference of one summand to the next):
- 0 2 4 6 8
- x :
- 0 1 2 3 4
- f(x) := x*2 :
- 0 2 4 6 8
- h(x) := (2x+1)^2 :
- 1 (2+1)^2=9 (4+1)^2=25 49 81
- Note that this is always the last of the quertet.
- Now we take that number 4 times because each block is:
- [ h(x)-3f(x) + h(x)-2f(x) + h(x)-f(x) + h(x) ] = 4h(x)-6f(x)
- g(h) := g(x-1) + 4*h(x) - 6*f(x)
- 1 25 101 261 537
- That doesn't mean that it has to be recursive.
- With a bit of magic (also know as mathematics) you get this formula:
- g(x) := 1 + 2/3 x (13 + x (15 + 8 x))

RAW Paste Data