summaryrefslogtreecommitdiffstats
path: root/01-algorithmic_toolbox/01-intro/01-fibonacci/fibonacci.cpp
diff options
context:
space:
mode:
Diffstat (limited to '01-algorithmic_toolbox/01-intro/01-fibonacci/fibonacci.cpp')
-rw-r--r--01-algorithmic_toolbox/01-intro/01-fibonacci/fibonacci.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/01-algorithmic_toolbox/01-intro/01-fibonacci/fibonacci.cpp b/01-algorithmic_toolbox/01-intro/01-fibonacci/fibonacci.cpp
new file mode 100644
index 0000000..adc7404
--- /dev/null
+++ b/01-algorithmic_toolbox/01-intro/01-fibonacci/fibonacci.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+
+int calc_fib(int n) {
+ if (n <= 1)
+ return n;
+
+ return calc_fib(n - 1) + calc_fib(n - 2);
+}
+
+int main() {
+ int n = 0;
+ std::cin >> n;
+
+ std::cout << calc_fib(n) << '\n';
+ return 0;
+}