chore: import upstream snapshot with attribution
Awesome CI Workflow / Code Formatter (push) Has been cancelled
Awesome CI Workflow / Compile checks (macOS-latest) (push) Has been cancelled
Awesome CI Workflow / Compile checks (ubuntu-latest) (push) Has been cancelled
Awesome CI Workflow / Compile checks (windows-latest) (push) Has been cancelled
Awesome CI Workflow / Code Formatter (push) Has been cancelled
Awesome CI Workflow / Compile checks (macOS-latest) (push) Has been cancelled
Awesome CI Workflow / Compile checks (ubuntu-latest) (push) Has been cancelled
Awesome CI Workflow / Compile checks (windows-latest) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int fib(int n) {
|
||||
int res[3];
|
||||
res[0] = 0;
|
||||
res[1] = 1;
|
||||
for (int i = 2; i <= n; i++) {
|
||||
res[2] = res[1] + res[0];
|
||||
res[0] = res[1];
|
||||
res[1] = res[2];
|
||||
}
|
||||
return res[1];
|
||||
}
|
||||
int main() {
|
||||
int n;
|
||||
cout << "Enter n: ";
|
||||
cin >> n;
|
||||
cout << "Fibonacci number is ";
|
||||
cout << fib(n) << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user