Problem 49 in Julia