Cycles and iterations

Report a typo

Look at the following code:

fun fibonacci() {
    var prev = 0
    var current = 1
    for (i in 0..24) {
        val swap = prev
        prev = current
        current += swap
        println(current)
    }
}

What is the value of the current variable at the end of the 20th iteration (i == 19)?

Enter a number
___

Create a free account to access the full topic