Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
269 B
1
Indexable
#include <iostream>
using namespace std;
int main()
{
	int fib1 = 0, fib2 = 1, fib3, i, n;
	cin >> n;
	if (n != 0) {
		for (i = 0; i < n - 1; i++)
		{
			fib3 = fib2;
			fib2 = fib1 + fib2;
			fib1 = fib3;
		}
		cout << fib2;
	}
	else { cout << 0; }
}