diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2022-01-29 19:17:17 +0100 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2022-01-29 19:20:50 +0100 |
commit | 9ff679d025151184818542a155065da5dbcbc5a1 (patch) | |
tree | 7c5fd2390b4425d544d154a80dcea381f353370d | |
parent | 24b3966960a65775bfffca514600e2e47304d000 (diff) | |
download | projecteuler-9ff679d025151184818542a155065da5dbcbc5a1.tar.gz |
003: Add fully functional elixir solution
-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 + |