A clown can climb a staircase either by one step or by two steps. For example, he can climb from the floor to the first step and then to the third, or he can climb from the floor to the first step, then to the second, and then finally to the third.
If a staircase has 10 steps, in how many ways can the clown climb it?
Clarification:
Bonus: Generalize it.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Brilliant approach! And a good observation too! (+1)
That's exactly what I thought.
Let the total number of steps be n . Let the number of double steps be x and single steps be y .
Then we have 2 x + y = 1 0
When the number of double steps is x , the corresponding value of y will be n − 2 x .
Thus, the possible number of ways of climbing up will be
( n − 2 x x + n − 2 x ) = ( n − 2 x n − x )
Therefore, total number of possible ways will be sum of all the possible ways of climbing up for each each value of x, i.e., :
= x = 0 ∑ p ( n − 2 x n − x )
where p is the maximum value of x which is ⌊ 2 n ⌋ .
Here we have n=10, hence the number of ways:
⇒ x = 0 ∑ 5 ( 1 0 − 2 x 1 0 − x )
⇒ 8 9
I didn't notice this approach! Great solution.
(sorry about formatting ... line breaks?)
Actually I was working on the 11 stair problem which was presented last week but didn't finish before it disappeared. I was looking for a pattern and saw the Fibonacci at times, but not always. <br> So went for a brute force method. <br> Ended up representing the paths that can be taken as a binary number where 1 represents 1 step, and 0 represents 2 steps. <br> 10 stairs
1111111111 = 1 way to take 10 single steps
<br>
111111110 = 9 ways with to take 1 double and 8 single (# <= this with 8 1's )
<br>11111100 = 28 ways to take 2 double and 6 single (# <= this with 6 1's )
<br>1111000 = 35 ways to take 3 double and 4 single (# <= this with 4 1's)
<br>110000 = 15 ways to take 4 double and 2 single (# <= this with 2 1's)
<br>00000 = 1 way to take 5 double
<br>
Total = 89 ways to traverse the stairs
<br>
I used a routine to count the number of occurrences of the 1 in the binaries in the range that was required to reach the maximum value represented in each grouping on the left.
<br>
Is there a formula to say how many ways someone can take 2 double and 6 single for example?
Problem Loading...
Note Loading...
Set Loading...
Let A(n) be the ways that the Clown can climb the n stairs. If he decides to take one step for his first move, there will be A(n-1) ways to climb the rest. If he decides to take two steps for his first move, there will be A(n-2) ways to climb the rest. Thus, A(n)=A(n-1)+A(n-2). This is the formula of the Fibonacci sequence. Hence, A(10)=F(11)=89