CAP/MiniC/TP03/tests/students/base/test_fibonacci.c
2024-10-10 11:37:00 +02:00

28 lines
414 B
C

#include "printlib.h"
int main() {
int num, result, i;
int prev1, prev2, tmp;
result = -1;
num = 15;
if (num < 2) {
result = num;
} else {
prev1 = 1;
prev2 = 0;
for i=2 to num {
tmp = prev1;
prev1 = prev1 + prev2;
prev2 = tmp;
}
result = prev1+prev2;
}
println_int(result);
return 0;
}
// SKIP TEST EXPECTED
// EXPECTED
// 610