Factorial

Lab C++ Beginner 10 points

Read n (0–20) and print n! using unsigned long long.

Input

One integer.

Output

n!

Example

Input

5

Output

120
Sample input available Sample output available
Editor
C++

Hints

20! fits in 64 bits.

Solution explanation

unsigned long long holds values up to about 1.8 × 10¹⁹.

Show solution
#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    unsigned long long f = 1;
    for (int i = 2; i <= n; i++) f *= i;
    cout << f << "\n";
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD