Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # elixir solution to codeabbey challenge 71
- defmodule Fnc do
- def while(f1, f2, m, idx) do
- f3 = rem (f1 + f2), m
- c = rem f3, m
- if c == 0 do
- IO.puts idx
- else
- while(f2, f3, m, idx+1)
- end
- end
- def getidxfib(mod) do
- while(0, 1, mod, 2)
- end
- def forloop(array, limit, n) do
- if limit != n do
- getidxfib(Enum.at(array, n))
- forloop(array, limit, n + 1)
- end
- end
- end
- defmodule Main do
- def func(:eof) do
- end
- def main do
- ncases = 19
- cases = [449825, 940999, 891051, 674588, 241652, 1049193, 1024240, 857743, 408165, 641261, 349920, 1015891, 982578, 291607, 657942, 374884, 508055, 458138, 732856]
- Fnc.forloop(cases, ncases, 0)
- end
- end
- Main.main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement