From 350a7ebb4eee4a4636674e14431d195e68b49f27 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Sun, 7 Nov 2021 19:06:00 +0000 Subject: - Tidied up guest contribution by Laurent Rosenfeld. --- challenge-137/laurent-rosenfeld/julia/ch-1.jl | 16 ---------------- challenge-137/laurent-rosenfeld/julia/ch-2.jl | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 challenge-137/laurent-rosenfeld/julia/ch-1.jl create mode 100644 challenge-137/laurent-rosenfeld/julia/ch-2.jl diff --git a/challenge-137/laurent-rosenfeld/julia/ch-1.jl b/challenge-137/laurent-rosenfeld/julia/ch-1.jl deleted file mode 100644 index 4ea2aff39a..0000000000 --- a/challenge-137/laurent-rosenfeld/julia/ch-1.jl +++ /dev/null @@ -1,16 +0,0 @@ -function is_lychrel(n) - m = n - for k = 1:500 - if (n > 10_000_000) - return "$m is a Lychrel candidate. Reached the 1e7 limit" - end - rev = parse(Int64, reverse(string(n))) - if (n == rev) return 0 end - n += rev - end - return "$m is a lychrel candidate (made 500 iterations)"; -end - -for test in [10, 20, 30, 50, 100, 196] - println("$test -> $(is_lychrel(test))") -end diff --git a/challenge-137/laurent-rosenfeld/julia/ch-2.jl b/challenge-137/laurent-rosenfeld/julia/ch-2.jl new file mode 100644 index 0000000000..4ea2aff39a --- /dev/null +++ b/challenge-137/laurent-rosenfeld/julia/ch-2.jl @@ -0,0 +1,16 @@ +function is_lychrel(n) + m = n + for k = 1:500 + if (n > 10_000_000) + return "$m is a Lychrel candidate. Reached the 1e7 limit" + end + rev = parse(Int64, reverse(string(n))) + if (n == rev) return 0 end + n += rev + end + return "$m is a lychrel candidate (made 500 iterations)"; +end + +for test in [10, 20, 30, 50, 100, 196] + println("$test -> $(is_lychrel(test))") +end -- cgit