diff --git a/fibonacci/fibonacci.cpp b/fibonacci/fibonacci.cpp index bbbc3d41..39b6adcc 100644 --- a/fibonacci/fibonacci.cpp +++ b/fibonacci/fibonacci.cpp @@ -1,16 +1,17 @@ -#include - -template int Fib(){ return Fib() + Fib(); } -template <> int Fib<1>() { return 1; } -template <> int Fib<0>() { return 1; } - +//Fibonacci Series using Recursion +#include using namespace std; -int main() +int fib(int n) +{ + if (n <= 1) + return n; + return fib(n-1) + fib(n-2); +} + +int main () { - int num = 0; - cout << "Enter the number of terms: "; - cin >> num; - cout << "The fibonacci series: "; - cout << Fib() << endl; - return 0; + int n; + cin>>n; + cout<