param { number } n return { number } function ClimbStairs ( n ) { if ( n <= 2 ) { return n ; } else { return ClimbStairs ( n - 1 ) + ClimbStairs ( n - 2 ) ; } } param { number } n param { number [ ] } memory return { number } function ClimbStairsWithMemory ( n , memory ) { if ( ! memory ) { memory = [ ] ; } if ( n <= 2 ) { return n ; } if ( ! memory [ n ] ) { memory [ n ] = ClimbStairsWithMemory ( n - 1 , memory ) + ClimbStairsWithMemory ( n - 2 , memory ) ; } return memory [ n ] ; } export { ClimbStairs , ClimbStairsWithMemory } ;