Problem 30 in Julia