Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a program to calculate the nth Fibonacci number using dynamic programming.

Medium

Problem 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)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
n = 10
Expected Output
The 10-th Fibonacci number is: 55