From dbdce2c71e8327d5cbfa3e87840866b504efec0f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 5 Jan 2024 08:21:16 +0200 Subject: [w10] Added solutions --- week10/ex2.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 week10/ex2.cpp (limited to 'week10/ex2.cpp') diff --git a/week10/ex2.cpp b/week10/ex2.cpp new file mode 100644 index 0000000..3d3e9a1 --- /dev/null +++ b/week10/ex2.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