4 ms·
int fibonacci(int n) { if (n <= 0) return 0; if (n == 1) return 1; int a = 0, b = 1, temp; for (int i = 2; i <= n; i++) { temp = a +
by Pet_Ant 1y ago
int fibonacci(int n) {
if (n <= 0) return 0;
if (n == 1) return 1;
int a = 0, b = 1, temp;
for (int i = 2; i <= n; i++) {
temp = a + b;
a = b;
b = temp;
}
return b;
}
...if only the return type was "Crow" then you could .eat() that...
- zabzonk 1y agoThat will not compile with javac, as it is not a method of a class.