When we look at dartlang.org’s home page and see an editor and code for Dart launcher with several examples what we do is first run and modify. For the first change to modify the example of fibonacci and changing 20 by 200 (the first thing we thought) left the browser blocked because it is an exponential function.
This is the original code:
int fib(int n) {
if (n < 2) return n;
return fib(n - 1) + fib(n - 2);
}
main() {
print('fib(20) = ${fib(20)}');
}
If you change it to print the complete list of the sequence of values of the function you can see how it comes to crash the browser:
Español


Recent Comments