aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-153/laurent-rosenfeld/julia/ch-2.jl17
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-153/laurent-rosenfeld/julia/ch-2.jl b/challenge-153/laurent-rosenfeld/julia/ch-2.jl
new file mode 100644
index 0000000000..e81b22369c
--- /dev/null
+++ b/challenge-153/laurent-rosenfeld/julia/ch-2.jl
@@ -0,0 +1,17 @@
+fact = map(x -> factorial(x), Vector(0:9))
+
+function is_factorion(num)
+ sum = 0
+ start_num = num
+ for n in 1:length(string(num))
+ sum += fact[num % 10 + 1] # Julia arrays start at 1
+ num = num รท 10
+ end
+ return sum == start_num
+end
+
+for i in 1:50000
+ if is_factorion(i)
+ println(i)
+ end
+end