Skip to content

Commit

Permalink
added nth-fibonacci-number-in-C++
Browse files Browse the repository at this point in the history
  • Loading branch information
aritrochakraborty29 committed Oct 6, 2020
1 parent 9951eee commit 860fd75
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions nth-fibonacci-number-in-C++/fibonacci.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include<iostream>
using namespace std;

int Fib(int n)
{
if(n<=1)
return n;
return Fib(n-1)+Fib(n-2); /*recusively add the numbers*/
}

int main()
{
int n; /*position of the element starting from 0...n*/
cout<<"Enter the number :";
cin>>n;
cout<<"Number at "<<n<<"th place is "<<Fib(n)<<endl;
return 0;
}

Binary file added nth-fibonacci-number-in-C++/fibonacci.exe
Binary file not shown.

0 comments on commit 860fd75

Please sign in to comment.