Problem 16 in Julia