Problem_52 solution