1
$\begingroup$

There is a staircase and some person say X can take 1 step or 2 steps . So how many ways can he take in total to climb up the staircase where there are n steps in total. Also what will be the minimum steps for him to climb up the staircase ? I think the number of minimum steps would be $\frac{n}{2}$ if $n$ is even and $\frac{n}{2}$ +$1$ if $n$ is odd but not sure about the total number of ways .

1 Answers 1

2

Total number of ways to climb the staircase is given recursively as:

T(n) = T(n-1) + T(n-2) for n >= 3.

T(1) = 1

T(2) = 2

The minimum number of steps to climb is n/2 if n is even else [n/2] + 1 where [x] denotes greatest integer less than or equal to x.

  • 0
    Oh yeah silly me!2012-09-05