Want to get the Fibonacci series program in kotlin. Use the following kotlin program to get the Fibonacci series program using kotlin.
1 2 3 4 5 6 7 8 9 10 11 12 13 | fun main(args: Array<String>) { val n = 10 var t1 = 0 var t2 = 1 print("First $n terms: ") for (i in 1..n) { print("$t1 + ") val sum = t1 + t2 t1 = t2 t2 = sum } } |
Program Output
1 | First 10 terms: 0 + 1 + 1 + 2 + 3 + 5 + 8 + 13 + 21 + 34 + |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.