Print Fibonacci number F(9).
| Test | Status | Details |
|---|
Ready — edit the code above and click Run or Submit.
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
int n = 9;
int a = 0, b = 1;
for (int k = 0; k < n; k++) { int t = a + b; a = b; b = t; }
Console.WriteLine(a);
}
}
Try solving on your own first, then reveal the official answer.
Bottom-up DP for Fibonacci.