The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Javascript
By Guest on 6th March 2019 02:50:30 AM | Syntax: JAVASCRIPT | Views: 53



New paste | Download | Show/Hide line no. | Copy text to clipboard
  1. var i;
  2. var fib = []; // Initialize array!
  3.  
  4. fib[0] = 0;
  5. fib[1] = 1;
  6. for (i = 2; i <= 10; i++) {
  7.   // Next fibonacci number = previous + one before previous
  8.   // Translated to JavaScript:
  9.   fib[i] = fib[i - 2] + fib[i - 1];
  10.   console.log(fib[i]);
  11. }



  • Recent Pastes