Submission
Status:
----------
Score: 0
User: un8qe_x3
Problemset: อนุกรม
Language: cpp
Time: 0.002 second
Submitted On: 2025-03-14 12:12:48
#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 << "INPUT " << npt << "\r\n";
cout << "OUTPUT " ;
cout << fib(npt) << endl;
return 0;
}