Skip to content

Commit

Permalink
Create fibonacciGenerator.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshitha-Killi authored Apr 30, 2022
1 parent 3804e9b commit 00caa9a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions fibonacciGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function fibonacciGenerator (n) {
var output = [0];

for (var i = 1; i < n; i++){

if(i===1){

output.push(i);

}

else {

output.push(output[i-1]+output[i-2]);

}

}

return output;
}

0 comments on commit 00caa9a

Please sign in to comment.