Implemented Problem 39