Skip to content
This repository was archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #47 from Gaminee/patch-1
Browse files Browse the repository at this point in the history
fibonacci.cpp
  • Loading branch information
avichalsri authored Oct 31, 2020
2 parents d97bfb4 + 7718509 commit cedf712
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fibonacci.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include<iostream>
using namespace std;

int Fib(int n)
{
if (n == 0 || n == 1)
{
return n;
}
else {
return Fib(n-1) + Fib(n-2);
}
}

int main(){
int n,j=0;
cout << "Enter the total number of terms:";
cin >> n;

for(int i=1; i<=n; i++)
{
int r = Fib(j);
cout << r << " ";
j++;
}
}

0 comments on commit cedf712

Please sign in to comment.