1
+ /*
2
+ written by Pankaj Kumar.
3
+ country:-INDIA
4
+ */
5
+ #include < bits/stdc++.h>
6
+ using namespace std ;
7
+ typedef long long ll ;
8
+ typedef set<pair<int ,int >> spi;
9
+ typedef set<pair<ll,ll>> spl;
10
+ typedef vector<pair<int ,int >> vpi;
11
+ typedef vector<int > vi;
12
+ typedef vector<ll> vl;
13
+ typedef vector<bool > vb;
14
+ typedef vector<char > vc;
15
+ typedef vector<pair<ll,ll>> vpl;
16
+ typedef vector<string> vs;
17
+ typedef map<int ,int >mi;
18
+ typedef map<ll,ll> ml;
19
+ typedef set<string> ss;
20
+ typedef set<char >sc;
21
+ typedef set<int > si;
22
+ typedef set<ll> sl;
23
+ #define pan cin.tie(0 );cout.tie(0 );ios_base::sync_with_stdio(0 );
24
+ // define values.
25
+ #define mod 1000000007
26
+ #define phi 1.618
27
+ /* Bit-Stuff */
28
+ #define get_set_bits (a ) (__builtin_popcount(a))
29
+ #define get_set_bitsll (a ) ( __builtin_popcountll(a))
30
+ #define get_trail_zero (a ) (__builtin_ctz(a))
31
+ #define get_lead_zero (a ) (__builtin_clz(a))
32
+ #define get_parity (a ) (__builtin_parity(a))
33
+ /* Abbrevations */
34
+ #define ff first
35
+ #define ss second
36
+ #define mp make_pair
37
+ #define line cout<<endl;
38
+ #define pb push_back
39
+ #define Endl " \n "
40
+ // loops
41
+ #define loop (i,start,end ) for (ll i=ll(start);i<ll(end);i++)
42
+ #define loop0 (num ) for (ll i=0 ;i<ll(num);i++)
43
+ #define forin (arr,n ) for (ll i=0 ;i<n;i++) cin>>arr[i];
44
+ // Some print
45
+ #define no cout<<" NO" <<endl;
46
+ #define yes cout<<" YES" <<endl;
47
+ #define cc ll test;cin>>test;while (test--)
48
+ // sort
49
+ #define all (V ) (V).begin(),(V).end()
50
+ #define srt (V ) sort(all(V))
51
+ #define srtGreat (V ) sort(all(V),greater<ll>())
52
+ // function
53
+
54
+ ll power (ll x,ll y)
55
+ {
56
+ ll res=1 ;
57
+ while (y>0 )
58
+ {
59
+ if (y%2 ==1 )res*=x;
60
+ y/=2 ; x*=x;
61
+ }
62
+ return res;
63
+ }
64
+ /* ascii value
65
+ A=65,Z=90,a=97,z=122
66
+ */
67
+ /* -----------------------------------------------------------------------------------*/
68
+ ll multiply (ll x,ll res[],ll res_size)
69
+ {
70
+ ll carry=0 ;
71
+ loop (i,0 ,res_size)
72
+ {
73
+ ll prod=res[i]*x+carry;
74
+ res[i]=prod%10 ;
75
+ carry=prod/10 ;
76
+ }
77
+ while (carry)
78
+ {
79
+ res[res_size]=carry%10 ;
80
+ carry=carry/10 ;
81
+ res_size++;
82
+ }
83
+ return res_size;
84
+ }
85
+
86
+ ll factorial (ll n)
87
+ {
88
+ ll res[500 ];
89
+ res[0 ]=1 ;
90
+ ll res_size=1 ;
91
+ loop (i,2 ,n+1 )
92
+ {
93
+ res_size=multiply (i,res,res_size);
94
+ }
95
+ for (ll i=res_size-1 ;i>=0 ;i--)
96
+ cout<<res[i];
97
+ return 0 ;
98
+ }
99
+
100
+ int main ()
101
+ {
102
+ // freopen("input.txt"a, "r", stdin);
103
+ pan;
104
+ ll n;
105
+ cin>>n;
106
+ cout<<" factorial of given number is : " ;
107
+ factorial (n);
108
+ line;
109
+ }
0 commit comments