mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-16 07:28:52 +00:00
Reorganize tests
This commit is contained in:
20
examples/c/fib3.c
Normal file
20
examples/c/fib3.c
Normal file
@@ -0,0 +1,20 @@
|
||||
int fibonacci(int n) {
|
||||
int i = 0;
|
||||
int t1 = 0, t2 = 1, next_term = 0;
|
||||
|
||||
if (n < 2) {
|
||||
return n;
|
||||
}
|
||||
|
||||
for (i = 1; i < n; ++i) {
|
||||
next_term = t1 + t2;
|
||||
t1 = t2;
|
||||
t2 = next_term;
|
||||
}
|
||||
|
||||
return t2;
|
||||
}
|
||||
|
||||
int main() {
|
||||
return fibonacci(9) == 34;
|
||||
}
|
||||
Reference in New Issue
Block a user