মডিউল ১৭_৭ঃ Bottom up approach in Fibonacci series


Last updated


Last updated
// Some code
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
int a[n];
a[0] = 0;
a[1] = 1;
// O(N)
for (int i = 2; i <= n; i++)
{
a[i] = a[i - 1] + a[i - 2];
}
cout << a[n] << endl;
return 0;
}