Rewrite problem #20 in Julia