OVMS3/OVMS.V3/components/duktape/examples/guide/fib.js

17 lines
259 B
JavaScript
Raw Normal View History

// fib.js
function fib(n) {
if (n == 0) { return 0; }
if (n == 1) { return 1; }
return fib(n-1) + fib(n-2);
}
function test() {
var res = [];
for (i = 0; i < 20; i++) {
res.push(fib(i));
}
print(res.join(' '));
}
test();