You are viewing a single comment's thread. Return to all comments →
The required expression is,
which is,
The expression can be recursively calculated as,
Using sum of consecutive natural numbers,
It can also be made efficient by caching computed values (, so a cache with a size of should be sufficient). In Python, it is even simpler with,
import functools @functools.lru_cache(maxsize = 10000) def SumSquaredifference(n): if(n == 1): return 0 return SumSquaredifference(n-1)+((n**2)*(n-1))
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #6: Sum square difference
You are viewing a single comment's thread. Return to all comments →
The required expression is,
which is,
The expression can be recursively calculated as,
Using sum of consecutive natural numbers,
It can also be made efficient by caching computed values (, so a cache with a size of should be sufficient). In Python, it is even simpler with,