fun fib(n: Int): Int {
var f1 = 1
var f2 = 1
for (i in 3 until n + 1) {
val f3 = f1 + f2
f1 = f2
f2 = f3
}
return f2
}
fun main() {
val n = 10
val result = fib(n)
println("fib($n) = $result")
}
ZnVuIGZpYihuOiBJbnQpOiBJbnQgewogIHZhciBmMSA9IDEKICB2YXIgZjIgPSAxCgogIGZvciAoaSBpbiAzIHVudGlsIG4gKyAxKSB7CiAgICB2YWwgZjMgPSBmMSArIGYyCiAgICBmMSA9IGYyCiAgICBmMiA9IGYzCiAgfQoKICByZXR1cm4gZjIKfQoKZnVuIG1haW4oKSB7CiAgdmFsIG4gPSAxMAoKICB2YWwgcmVzdWx0ID0gZmliKG4pCgogIHByaW50bG4oImZpYigkbikgPSAkcmVzdWx0IikKfQ==