Solved problem 76 much faster with generating function.