-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday12.cpp
More file actions
38 lines (34 loc) · 708 Bytes
/
day12.cpp
File metadata and controls
38 lines (34 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;
//Find factorial of very big numbers which cant be calculated using long long int
void multiply(int *a, int &n,int no){
int carry =0;
for(int i=0;i<n;i++){
int product = a[i]*no + carry;
a[i] = product%10;
carry=product/10;
}
while(carry!=0){
a[n]=carry%10;
carry=carry/10;
n++;
}
return;
}
void big_factorial(int number){
int *a = new int[100]{0};
a[0]=1;
int n=1;
for(int i=2;i<=number;i++){
multiply(a,n,i);
}
//Print
for(int i=n-1;i>=0;i--){
cout<<a[i];
}
cout<<endl;
}
int main(){
big_factorial(100);
return 0;
}