fun int recursive_fib(int n) {
if (n < 2)
return n;
- else
- return recursive_fib(n - 2) + recursive_fib(n - 1);
+ return recursive_fib(n - 2) + recursive_fib(n - 1);
}
<<< 40 => recursive_fib >>>;
@```
See the memoized version of previous function:
@``` fib_recurs_memoize.gw
-#pragma memoize 2
fun int recursive_fib(int n) {
+#pragma memoize 2
if (n < 2)
return n;
- else
- return recursive_fib(n - 2) + recursive_fib(n - 1);
+ return recursive_fib(n - 2) + recursive_fib(n - 1);
}
<<< 40 => recursive_fib >>>;
@```