Counting: how many ways of climbing a stair?

Sure, that code looks fine. When I run my own version of the code, I get the Fibbonaci sequence— do you?

$$1,\ 2,\ 3,\ 5,\ 8,\ 13,\ 21,\ \cdots$$

This makes sense: suppose $F_n$ represents the number of ways of climbing $n$ steps. If we must climb $n$ steps, we have two choices: we can take 1 step first, then we will have $F_{n-1}$ choices. Or we can take 2 steps first, then we will have $F_{n-2}$ choices. In other words, $F_{n+1} = F_{n} + F_{n-1}$ total choices.

As a special base case, we have that $F_0 = 1$ (the base case in your program), and $F_1 = 1$.


This is a typical example of Fibonacci sequence.

To reach up to, say $N^{th}$ step, you need to get to either $(N-1)^{th}$ or $(N-2)^{th}$ step. It is true for all values of $N$ where $N$ is ${1,2,3...}$.
This is thus a recursion, as is evident from your code:

if (numStairs-BIG>=0) return CountWays(numStairs-SMALL)+CountWays(numStairs-BIG); else return CountWays(numStairs-SMALL);