Work in progress on Problem 38
Solve Problem 36