Write a program to calculate the nth Fibonacci number using dynamic programming.
MediumProblem Statement
Write a program to calculate the nth Fibonacci number using dynamic programming.
Sample Input
n = 10
Sample Output
The 10-th Fibonacci number is: 55
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
fun fibonacci(n: Int): Int {
// Add your code here to calculate the nth Fibonacci number
}
fun main() {
val n = 10
println("The $n-th Fibonacci number is: ${fibonacci(n)}")
}
Input
n = 10
Expected Output
The 10-th Fibonacci number is: 55