aboutsummaryrefslogtreecommitdiffstats
path: root/003.ex
blob: 8d07a5dcddc5ce5bed81506e736aee3900208724 (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.