compiler-design-eth/javali_tests/HW4/FibonacciRecursive.javali

24 lines
289 B
Text
Raw Permalink Normal View History

2020-01-15 22:34:57 +01:00
class Main {
void main() {
int a;
a = fib(20);
write(a);
writeln();
}
int fib(int n) {
int fib;
int fib2;
if (n <= 1) {
fib = n;
} else {
fib = fib(n-1);
fib2 = fib(n-2);
fib = fib + fib2;
}
return fib;
}
}