Euler 92 solved using some smart caching