summaryrefslogtreecommitdiff
path: root/c/factorial.c
diff options
context:
space:
mode:
authorpants <niklasjo2004@gmail.com>2026-09-21 14:17:03 -0700
committerpants <niklasjo2004@gmail.com>2026-09-21 14:17:03 -0700
commit7b21727285e50b0b050c4ddd70d07542229c5366 (patch)
tree5d369153c5df5b41f3750d25479a68f20169c8ff /c/factorial.c
init
Diffstat (limited to 'c/factorial.c')
-rw-r--r--c/factorial.c18
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;
+}