mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-19 14:49:48 +01:00
333d9a4053
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
11 lines
245 B
TypeScript
11 lines
245 B
TypeScript
function fibonacci_iterative(n: number): number {
|
|
if (n === 1) return 0;
|
|
if (n === 2) return 1;
|
|
let a = 0, b = 1, sum = 0;
|
|
for (let i = 2; i < n; i++) {
|
|
sum = a + b;
|
|
a = b;
|
|
b = sum;
|
|
}
|
|
return sum;
|
|
} |