Submission
Status:
-PPPP-----
Score: 40
User: exoworldgd
Problemset: อนุกรม
Language: cpp
Time: 0.003 second
Submitted On: 2024-12-14 17:53:40
#include <iostream>
using namespace std;
int main(void) {
int n, a = 0, b = 1, fib;
cin >> n;
if (n == 1) {
cout << 0;
return 0;
}
if (n == 2) {
cout << 1;
return 0;
}
for (int i = 1; i < n; i++) {
fib = a + b;
a = b;
b = fib;
}
cout << b;
}