aboutsummaryrefslogtreecommitdiff
path: root/week11/ex1.cpp
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2024-01-05 08:59:38 +0200
committerSyndamia <kamen@syndamia.com>2024-01-05 08:59:38 +0200
commit7e7c710287f25b9c958c9026b18f88587174d47f (patch)
tree7eba964d18ec76111c24deca68fb2aea27e85005 /week11/ex1.cpp
parentdbdce2c71e8327d5cbfa3e87840866b504efec0f (diff)
downloadupp-2023-solutions-7e7c710287f25b9c958c9026b18f88587174d47f.tar
upp-2023-solutions-7e7c710287f25b9c958c9026b18f88587174d47f.tar.gz
upp-2023-solutions-7e7c710287f25b9c958c9026b18f88587174d47f.zip
[w11] Added solutions
Diffstat (limited to 'week11/ex1.cpp')
-rw-r--r--week11/ex1.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/week11/ex1.cpp b/week11/ex1.cpp
new file mode 100644
index 0000000..3d3e9a1
--- /dev/null
+++ b/week11/ex1.cpp
@@ -0,0 +1,12 @@
+#include <iostream>
+
+int fibIndex(const int N, int count = 0, int a = 0, int b = 1) {
+ if (N == a) return count;
+ return fibIndex(N, count + 1, b, a+b);
+}
+
+int main() {
+ int N;
+ std::cin >> N;
+ std::cout << fibIndex(N) << std::endl;
+}