From 7e7c710287f25b9c958c9026b18f88587174d47f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 5 Jan 2024 08:59:38 +0200 Subject: [w11] Added solutions --- week11/ex1.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 week11/ex1.cpp (limited to 'week11/ex1.cpp') 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 + +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; +} -- cgit v1.2.3