Skip to content

Commit 0f505d5

Browse files
committed
Added climbing stairs algorithm
1 parent af0b0bb commit 0f505d5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var countWays = function(steps){
2+
if(steps <= 1)
3+
return 1;
4+
5+
return countWays(steps - 1) + countWays(steps - 2);
6+
}
7+
8+
console.log(countWays(4)) // return 5
9+
console.log(countWays(5)) // return 8

0 commit comments

Comments
 (0)