aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--003.ex9
1 files changed, 9 insertions, 0 deletions
diff --git a/003.ex b/003.ex
new file mode 100644
index 0000000..83bc349
--- /dev/null
+++ b/003.ex
@@ -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
+
remember that computers suck.