alternate solutions for problem 18 using memoization. still not as fast as the reverse summing