Problem number 3 rewritten in Julia