Website Summary Files Commits Branches @commit @diff @stats
path: root / Week04 / Exercise13.cpp
blob: 953ee61567ed41bced97b7a37c134775362e51bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;
}