Kodewick
Start learning →
Starter←→0 / 50

Factorial

#010Starterf *= i3 min

The factorial of n, written n!, is 1 times 2 times … up to n: 5! = 1 × 2 × 3 × 4 × 5 = 120. By rule, 0! = 1. Write factorial(n) to return n! (n is from 0 to 20).

Examples
factorial(5)→120
factorial(3)→6
factorial(1)→1
The functionlong long factorial(int n)
main.c
long long factorial(int n) {
    long long f = 1;
    for (int i = 1; i <= n; i++) {
        // your code here: multiply f by i
    }
    return f;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.