Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. //Generates a fibonacci sequency of length [fiboLength] and then prints the result to the console.
  2. //[fibo] array to hold generated values, initialized with first two numbers in the sequence.
  3. //[fiboLength] number of values to be generated
  4. let fibo = [0,1], fiboLength = 10;
  5. for(let i=0; i < (fiboLength - 2); i++) {
  6. fibo.push( fibo[fibo.length - 2] + fibo[fibo.length - 1] );
  7. }
  8. console.log( fibo.join( ', ') );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement