Skip to content

Instantly share code, notes, and snippets.

@dherman
Forked from hagino3000/fibonacci.js
Last active December 28, 2016 21:12
Show Gist options
  • Save dherman/30f60f46f182f247b2aac7d71c33dee7 to your computer and use it in GitHub Desktop.
Save dherman/30f60f46f182f247b2aac7d71c33dee7 to your computer and use it in GitHub Desktop.
asm.js sample
function fast_fib_module(stdlib, foreign, heap) {
"use asm";
function fib(n) {
n = n|0;
if (n >>> 0 < 3) {
return 1|0;
}
return (fib((n-1)|0) + fib((n-2)|0))|0;
}
return fib;
}
fast_fib = fast_fib_module(window);
function slow_fib(n) {
if (n < 3) {
return 1;
}
return slow_fib(n-1) + slow_fib(n-2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment