Hopping rabbit

A rabbit sits at the bottom of a staircase with n stairs.rabbit can hop up only one or two stairs at a time.how many different ways are there two reach at top of stair.

Comments

  1. Hint: use induction approach before reaching nth stair he can be either at n-1 or n-2 stairs.

    ReplyDelete
  2. Suppose W(n) different ways are there two reach at top of stair.

    Now
    W(1) = 1 [It can be done by a single step only]
    W(2) = 2 [It can be done by taking two stairs at one time or 2 steps of one stair]

    W(3) = W(2) + W(1) [1st reach upto stair #1 and then move to stair #3 by taking double step or
    1st reach upto stair #2 and then move to stair #3 by taking single step]

    Similarly W(n) = W(n-1) + W(n-2)

    ReplyDelete
  3. @Hsingh you are right.The sequence generated is like fibonacci series.

    ReplyDelete

Post a Comment

Popular posts from this blog