Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0db576
commit 384418f
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* @author : dhruv-gupta14 | ||
* @date : 8/01/2019 | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
long long calc_fact(long long n) | ||
{ | ||
if (n <= 1) | ||
return 1; | ||
return n*calc_fact(n-1); | ||
} | ||
int main() | ||
{ | ||
long long n; | ||
cin>>n; | ||
cout<<calc_fact(n)<<endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* @author : dhruv-gupta14 | ||
* @date : 8/01/2019 | ||
*/ | ||
|
||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
long long fib_num(long long n) | ||
{ | ||
if (n <= 2) | ||
return 1; | ||
return fib_num(n-1)+fib_num(n-2); | ||
} | ||
int main() | ||
{ | ||
long long n; | ||
cin>>n; | ||
cout<<fib_num(n)<<endl; | ||
return 0; | ||
} |