#include <iostream>
int Fibonacci(int n)
{
if ( n == 0) {
return 0 ;
}
if ( n == 1) {
return 1 ;
}
int first = 0 ;
int second = 1 ;
int third ;
for (int i = 2 ; i <= n ; i++) {
third = first + second ;
first = second ;
second = third ;
}
return third ;
}
int main()
{
std::cout<<Fibonacci(3)<<std::endl;
std::cout<<Fibonacci(4)<<std::endl;
std::cout<<Fibonacci(5)<<std::endl;
}
the most simple dynamic program