File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Given a number N. Print the factorial of number N.
2
+
3
+ #include < iostream> // iostream is a header file which contains basic input/output functions.
4
+ #include < iomanip> // iomanip is a header file which contains functions for input/output manipulations.
5
+ #include < cmath> // cmath is a header file which contains mathematical functions.
6
+ int main () {
7
+ int t; // Declaring variable t as integer.
8
+ cin >> t; // Taking input of t.
9
+ while (t--) { // Looping t times.
10
+ int n; // Declaring variable n as integer.
11
+ cin >> n; // Taking input of n.
12
+ long long int fact = 1 ; // Declaring variable fact as long long int and initializing it with 1.
13
+ for (int i = 2 ; i <= n; i++) // Looping from 2 to n.
14
+ fact *= i; // Multiplying fact with i.
15
+ cout << fact << endl; // Printing fact.
16
+ }
17
+ return 0 ; // Return 0 to indicate that the program ended successfully.
18
+ // End of program
19
+ }
You can’t perform that action at this time.
0 commit comments