/*
    LOOP PRACTICE - Factorial (for loop)
    ------------------------------------
    Factorial of N = 1 * 2 * 3 * ... * N
    Example: 5! = 1*2*3*4*5 = 120
    Ask the user for N (e.g. 1 to 10), use a for loop to compute N!
*/

#include <stdio.h>

int main(void) {
    int n;
    int i;
    long long fact = 1;

    printf("Enter a number (1 to 20): ");
    scanf("%d", &n);

    if (n < 0) {
        printf("Factorial is not defined for negative numbers.\n");
        return 0;
    }

    for (i = 1; i <= n; i++) {
        fact = fact * i;
    }

    printf("%d! = %lld\n", n, fact);

    return 0;
}
