Website Summary Files Commits Branches @commit @diff @stats
path: root / Week04 / Exercise13.cpp
diff options
context:
space:
mode:
1 files changed, 19 insertions, 0 deletions
-rw-r--r--Week04/Exercise13.cpp19
diff --git a/Week04/Exercise13.cpp b/Week04/Exercise13.cpp
new file mode 100644
index 0000000..953ee61
--- /dev/null
+++ b/Week04/Exercise13.cpp
@@ -0,0 +1,19 @@
+#include <iostream>
+
+int main() {
+ unsigned int fib_index;
+ std::cin >> fib_index;
+
+ unsigned int prev = 0;
+ unsigned int curr = 1;
+
+ for (unsigned int index = 1; index <= fib_index; index++) {
+ unsigned int old_curr = curr;
+ curr += prev;
+ prev = old_curr;
+ }
+
+ std::cout << prev;
+
+ return 0;
+}