17.Dynamic Programming - Fibonachi
26 May 2020 | STL Programming Practice_1
    
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int fibonachi(int x)
{
    int y;
    if (x==0)
        return 0;
    if (x==1)
        return 1;
    if (x==2)
        return 1;
    y = (x-2)+(x-1);
    return y;
}
int main()
{
    int k = 5;
    int result = fibonachi(k);
    cout<<result;
    return 0;
}
   
  
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int fibonachi(int x)
{
    int y;
    if (x==0)
        return 0;
    if (x==1)
        return 1;
    if (x==2)
        return 1;
    y = (x-2)+(x-1);
    return y;
}
int main()
{
    int k = 5;
    int result = fibonachi(k);
    cout<<result;
    return 0;
}
 
             
             
             
          









Comments