31ph4n70m

Fibonacci_Divisibility_Advanced.ex

Nov 25th, 2019
629
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # elixir solution to codeabbey challenge 71
  2.  
  3. defmodule Fnc do
  4.     def while(f1, f2, m, idx) do
  5.         f3 = rem (f1 + f2), m
  6.         c = rem f3, m
  7.         if c == 0 do
  8.             IO.puts idx
  9.  
  10.         else
  11.             while(f2, f3, m, idx+1)
  12.         end
  13.     end
  14.    
  15.     def getidxfib(mod) do
  16.         while(0, 1, mod, 2)
  17.     end
  18.    
  19.     def forloop(array, limit, n) do
  20.         if limit != n do
  21.             getidxfib(Enum.at(array, n))
  22.             forloop(array, limit, n + 1)
  23.         end
  24.     end
  25.    
  26.    
  27. end
  28.  
  29. defmodule Main do
  30.     def func(:eof) do
  31.     end
  32.  
  33.     def main do
  34.         ncases = 19
  35.         cases = [449825, 940999, 891051, 674588, 241652, 1049193, 1024240, 857743, 408165, 641261, 349920, 1015891, 982578, 291607, 657942, 374884, 508055, 458138, 732856]
  36.         Fnc.forloop(cases, ncases, 0)
  37.     end
  38. end
  39.  
  40. Main.main
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×