Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 00caa9a

Browse files
Create fibonacciGenerator.js
1 parent 3804e9b commit 00caa9a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎fibonacciGenerator.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function fibonacciGenerator (n) {
2+
var output = [0];
3+
4+
for (var i = 1; i < n; i++){
5+
6+
if(i===1){
7+
8+
output.push(i);
9+
10+
}
11+
12+
else {
13+
14+
output.push(output[i-1]+output[i-2]);
15+
16+
}
17+
18+
}
19+
20+
return output;
21+
}
22+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /