• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Project Euler #28 DulcetAirman   Jul 20th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. https://projecteuler.net/problem=28
2.
3.
4. The series to get the result has this pattern:
5. 1 + [3 + 5 + 7 + 9] + [13 + 17 + 21 + 25 ] + [31 + 37 + 43 + 49] + [ 56 ...
6. There's always a quertet of four summands.
7. How many you skip between the 4 summands (difference of one summand to the next):
8. 0    2                 4                      6                      8
9.
10. x :
11. 0    1                 2                      3                      4
12. f(x) := x*2 :
13. 0    2                 4                      6                      8
14. h(x) := (2x+1)^2 :
15. 1    (2+1)^2=9         (4+1)^2=25            49                     81
16. Note that this is always the last of the quertet.
17. Now we take that number 4 times because each block is:
18. [ h(x)-3f(x) + h(x)-2f(x) + h(x)-f(x) + h(x) ] = 4h(x)-6f(x)
19. g(h) := g(x-1) + 4*h(x) - 6*f(x)
20. 1   25               101                    261                    537
21.
22. That doesn't mean that it has to be recursive.
23. With a bit of magic (also know as mathematics) you get this formula:
24. g(x) := 1 + 2/3 x (13 + x (15 + 8 x))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top