Problem 10 in Julia