Skip to content

Commit

Permalink
Bug fix: slow Fibonacci function
Browse files Browse the repository at this point in the history
- Updated to a way faster version, thanks to @vihanb
  • Loading branch information
ETHproductions committed Nov 23, 2015
1 parent 3d3dbf5 commit 0f4b5e1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/japt-interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ Number.prototype.z = function(){noFunc('Nz')}

// Shorter Math Properties
Math.t = Math.atan2;
Math.fib = Math.fib || [];
Math.g = function g (n) { return n <= 1 ? n : Math.fib[n]? Math.fib[n] : Math.fib[n] = Math.g(n-1) + Math.g(n-2); };
Math.g = function (n) { var f=Math.sqrt(5), g=.5*(1+f); return (1/f)*(Math.pow(g,n)-Math.pow(-g,-n)) };
Math.r = Math.random;
Math.P = Math.PI;
Math.h = Math.hypot || function hypot () {return Math.sqrt(arguments.reduce(function(a,b){return a+b*b}))};
Expand Down

0 comments on commit 0f4b5e1

Please sign in to comment.