diff options
Diffstat (limited to '003.ex')
-rw-r--r-- | 003.ex | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -0,0 +1,9 @@ +n = 600851475143 + +(for x <- 2..trunc(:math.sqrt(n / 2)), rem(n, x) == 0, do: x) +|> Enum.reduce_while(n, fn x, acc -> + if acc == x, do: {:halt, x}, else: {:cont, acc / x} + end) +|> trunc +|> IO.puts + |