diff options
Diffstat (limited to 'c/factorial.c')
| -rw-r--r-- | c/factorial.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/c/factorial.c b/c/factorial.c new file mode 100644 index 0000000..4ee0720 --- /dev/null +++ b/c/factorial.c @@ -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; +} |
