Solution for problem 39. perimeters of right triangles.