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