31ph4n70m

Fibonacci_Divisibility_Advanced.coffee

Nov 26th, 2019
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # coffeescript solution to codeabbey challenge 71
  2. getidxfib =(mod) ->
  3.     fib1 = 0; fib2=1; fib3 = 0; idx = 2
  4.     while true
  5.         fib3 = (fib1 + fib2) % mod
  6.         if fib3 % mod == 0
  7.             return idx
  8.         fib1 = fib2
  9.         fib2 = fib3
  10.         idx++;
  11.  
  12. N_CASES = 19
  13. CASES = [449825, 940999, 891051, 674588, 241652, 1049193, 1024240, 857743, 408165, 641261, 349920, 1015891, 982578, 291607, 657942, 374884, 508055, 458138, 732856]
  14. RSP = [getidxfib(c) for c in CASES]
  15. count = 0
  16. o = ""
  17. while count < RSP.length
  18.     o = o + RSP[count] + " "
  19.     count++;
  20.  
  21. console.log o
Add Comment
Please, Sign In to add comment