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 a5a7a34

Browse files
add fibonacci prb
1 parent 939f3c2 commit a5a7a34

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@
4444
| Problem - 40 | [Vowel and Consonant ](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-40.js) |
4545
| Problem - 41 | [Find month name. ](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-41.js) |
4646
| Problem - 42 | [Multiplication table. ](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-42.js) |
47+
| Problem - 43 | [ Fibonacci ](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-43.js) |
4748

48-
<!-- | Problem - 43 | | -->
49+
<!-- | Problem - 44 | | -->

‎problem-43.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function fibonacci(n){
2+
const fib = [0,1];
3+
for(let i = 2 ; i <n ; i++){
4+
fib[i] = fib[i - 1] + fib[i - 2]
5+
}
6+
7+
return fib
8+
}
9+
10+
console.log(fibonacci(10));
11+

0 commit comments

Comments
(0)

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