Skip to content

Instantly share code, notes, and snippets.

@jailsonsf
Created July 3, 2021 01:24
Show Gist options
  • Save jailsonsf/ada94da6c2e107917e3be57dde5a8d7b to your computer and use it in GitHub Desktop.
Save jailsonsf/ada94da6c2e107917e3be57dde5a8d7b to your computer and use it in GitHub Desktop.
Fibonacci in kotlin
fun main(args: Array<String>) {
val n = readLine()!!.toInt()
var sum : Int
var t1: Int = 0
var t2: Int = 1
for (i in 1..(n-1)) {
print("${t1} ")
sum = t1 + t2
t1 = t2
t2 = sum
}
print("$t1")
println()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment