c-repl/example/fibonacci_imp.c
2024-01-18 12:00:34 +01:00

17 lines
265 B
C

int num = 15;
int result = -1;
if (num < 2)
result = num;
else {
int prev1 = 1;
int prev2 = 0;
for (int i=2; i < num; i++)
{
int tmp = prev1;
prev1 = prev1 + prev2;
prev2 = tmp;
};
result = prev1+prev2;
}
result;