SHARE
TWEET

Untitled

a guest May 19th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fib(pos, fibValues) {
  2.     if (typeof fibValues[pos] !== "undefined") {
  3.         return fibValues[pos];
  4.     }
  5.  
  6.     result = fib(pos - 1, fibValues) + fib(pos - 2, fibValues);
  7.     fibValues[pos] = result;
  8.     return result;
  9. }
  10.  
  11. let fibValues = [1, 1];
  12. console.log(fib(30, fibValues));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top