Submission
Status:
PPPPP-----
Score: 50
User: un8qe_x3
Problemset: อนุกรม
Language: cpp
Time: 0.003 second
Submitted On: 2025-03-14 12:08:07
#include <iostream>
#include <string>
using namespace std;
int fib(int n) {
if (n == 0) {
return 0;
} else if (n == 1) {
return 1;
}
int a = 0, b = 1;
for (int i = 2; i <= n; i++) {
int temp = b;
b = a + b;
a = temp;
}
return b;
}
int main() {
int npt;
cin >> npt;
cout << fib(npt) << endl;
return 0;
}