Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- lua solution to codabbey challenge 71
- function getidxfib(mod)
- fib1 = 0
- fib2 = 1
- fib3 = 0
- idx = 2
- while (true)
- do
- fib3 = (fib1 + fib2) % mod
- if (fib3 % mod == 0)
- then
- return tostring(idx)
- end
- fib1 = fib2
- fib2 = fib3
- idx = idx + 1
- end
- end
- N_CASES = 19
- CASES = {449825, 940999, 891051, 674588, 241652, 1049193, 1024240, 857743, 408165, 641261, 349920, 1015891, 982578, 291607, 657942, 374884, 508055, 458138, 732856}
- RSP = {}
- for i=1,N_CASES do
- val = getidxfib(CASES[i])
- table.insert(RSP, val)
- end
- print(table.concat(RSP, " "))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement