Skip to content

Commit 3cc79c5

Browse files
committed
fibonaaci
1 parent bbac5b1 commit 3cc79c5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Programs/DSA/fibo.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
6. Wap in Js nth Fibonaaci number
3+
4+
5 =0 1 1 2 3 5 8 13 = 5
5+
6 =8
6+
*/
7+
8+
9+
10+
function fibo(num){
11+
12+
if(num===0||num===1){
13+
14+
return num;
15+
} else{
16+
17+
return fibo(num-1)+fibo(num-2)
18+
}
19+
}
20+
21+
console.log(fibo(6))//8
22+
console.log(fibo(5))//5

0 commit comments

Comments
 (0)