Solve problem #25 in Julia