init
This commit is contained in:
18
c/factorial.c
Normal file
18
c/factorial.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
|
||||
long fact(long n) {
|
||||
if (n == 0) {
|
||||
return 1;
|
||||
}
|
||||
else return(n*fact(n-1));
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("enter a POSITIVE integer... ");
|
||||
long input;
|
||||
scanf("%d", &input);
|
||||
long output = fact(input);
|
||||
printf("output: %lld\n", output);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user