#include <stdio.h>

// n! = n*(n-1)!
// 1! = 1, 0! = 1

int factorial(int n) {
	if (n < 0) {
		return -1;
	       // factorial function is defined for non-negative integers only
	}
	if (n == 1 || n == 0) {
		return 1;
	}
	return (n * factorial(n - 1));
}

/*
int factorial(int n) {
	int res;

	if (n == 1 || n == 0) {
		res = 1;
	} else {
		res = n * factorial(n - 1);
	}

	return res;
}
*/

int main() {
	int n;

	for(;;) {
		printf("Factorial de n. Intro n: ");
		scanf("%d", &n);
		printf("%d! =  %d\n", n, factorial(n));
	}
}

