Completed the first part of problem 35