previewcode_recursive.txt 203 Bytes
Newer Older
Mihai Herda's avatar
Mihai Herda committed
1
2
//Calculate the factorial of k recursively.
int fac(int k) {
3
	if (k <= 1)
Mihai Herda's avatar
Mihai Herda committed
4
5
6
7
8
9
10
11
12
13
14
15
		return 1;
	int res;
	res = fac(k-1);
	res = res * k;
	return res;
}

int main(int k) {
	int res;
	res = fac(k);
	return res;
}