Skip to content

Commit e285202

Browse files
authored
Add files via upload
1 parent ced1415 commit e285202

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

Factorial using Recursion.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
///Factorial using Recursion
2+
3+
/**
4+
*
5+
* author :: 101rror
6+
*
7+
**/
8+
9+
#include <bits/stdc++.h>
10+
11+
using namespace std;
12+
13+
#define MAX 100
14+
#define infinity 1000000000000000LL
15+
#define all(x) (x).begin(),(x).end()
16+
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
17+
#define mod(x,m) ((x%m)+m)%m; //101rror
18+
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
19+
20+
#define T while(t--)
21+
#define for2(i,a,b) for(i=a;i>=b;i--)
22+
#define for3(i,a,b) for(i=a;i<=b;i=i+2)
23+
#define for1(i,a,b) for(i=a;i<=b;i=i+1)
24+
#define for4(i,a,b) for(i=a;i>=b;i=i-2)
25+
26+
#define fi first
27+
#define se second
28+
#define pb push_back
29+
#define eb emplace_back
30+
31+
#ifdef LOCAL
32+
#include "algo/debug.h"
33+
#else
34+
#define debug(...) 42
35+
#endif
36+
37+
38+
int Factorial(int num)
39+
{
40+
if(num > 1)
41+
{
42+
return (num * Factorial(num - 1));
43+
}
44+
else
45+
{
46+
return 1;
47+
}
48+
}
49+
50+
int main()
51+
{
52+
ios::sync_with_stdio(false);
53+
cin.tie(0);
54+
fastread();
55+
56+
57+
int num;
58+
cin >> num;
59+
60+
cout << endl;
61+
cout << num << " Factorial is : " << Factorial(num);
62+
cout << endl;
63+
64+
65+
return 0;
66+
}

0 commit comments

Comments
 (0)