Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fibonacciGenerator (n) {
- //Do NOT change any of the code above 👆
- //Write your code here:
- if (n===1){
- return [0];
- }
- if (n===2){
- return [0,1];
- }
- var arr = [0,1];
- for(var i=2; i<n ; i++){
- arr.push(arr[i-1]+arr[i-2]);
- }
- return arr;
- //Return an array of fibonacci numbers starting from 0.
- //Do NOT change any of the code below 👇
- }
Advertisement
Add Comment
Please, Sign In to add comment