Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Kotlin solution to codeabbey challenge 71
- fun getidxfib(mod: Int): Int{
- var fib1: Int = 0
- var fib2: Int = 1
- var fib3: Int = 0
- var idx: Int = 2
- while (true){
- fib3 = (fib1 + fib2) % mod
- if (fib3 % mod == 0) {
- return idx
- }
- fib1 = fib2
- fib2 = fib3
- idx++
- }
- }
- fun main(args: Array<String>) {
- var N_CASES = 19
- var CASES: IntArray = intArrayOf(449825, 940999, 891051, 674588, 241652, 1049193, 1024240, 857743, 408165, 641261, 349920, 1015891, 982578, 291607, 657942, 374884, 508055, 458138, 732856)
- var RSP = IntArray(19)
- for(x in 0 until 19){
- RSP[x] = getidxfib(CASES[x])
- }
- println(RSP.joinToString(" "))
- }
Add Comment
Please, Sign In to add comment