aboutsummaryrefslogtreecommitdiffstats
path: root/003.ex
blob: 83bc3498c10ca4c74ca6f97d6ba72778f9d2923d (plain) (blame)
1
2
3
4
5
6
7
8
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

remember that computers suck.