-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20.cpp
More file actions
40 lines (38 loc) · 731 Bytes
/
20.cpp
File metadata and controls
40 lines (38 loc) · 731 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
39
40
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int multiply(vector<int>& arr, int m, int s){
int carry = 0;
for(int i=0;i<s;i++){
long long int p = (arr[i]*m) + carry;
arr[i] = p%10;
carry = p/10;
}
while(carry){
arr.push_back(carry%10);
carry /= 10;
s++;
}
return s;
}
int main() {
//program to find factorial of numbers above 10.
int t;
cin>>t;
for(int i=0;i<t;i++){
int n;
cin>>n;
vector<int> arr;
arr.push_back(1);
int s = 1;
for(int i=2;i<=n;i++){
s = multiply(arr, i, s);
}
for(int i=s-1;i>=0;i--){
cout<<arr[i];
}
cout<<endl;
arr.clear();
}
return 0;
}