summaryrefslogtreecommitdiff
path: root/factorial.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'factorial.hpp')
-rw-r--r--factorial.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/factorial.hpp b/factorial.hpp
new file mode 100644
index 0000000..ddc0bac
--- /dev/null
+++ b/factorial.hpp
@@ -0,0 +1,9 @@
+#pragma once
+
+long unsigned factorial(unsigned p) {
+ if (p == 0) {
+ return 1;
+ } else {
+ return p * factorial(p - 1);
+ }
+}