Solving Hari Prasad Misra's Staircase Problem with Max 2 Steps

  • Thread starter Thread starter s_chaursia
  • Start date Start date
s_chaursia
Messages
3
Reaction score
0
Hari Prasad Misra Of IT Branch has to climb up stairs daily to reach to his class room. But
daily he doesn’t manage to reach in the class room on time.
So, he decided to form a program which tells him in how many ways he can climb upstairs
and reach to his class room.
But he can climb Maximum of 2 Stairs at one time.
You need to write a program for him in order to calculate the NO. of possible ways to reach
when he can climb one step, two steps, or one or two steps both simultaneously to reach up
stairs.
Example:
Here No of stairs are =3
So the possible ways are 3 stairs
First way 1,1,1(steps)
Second way 1,2(steps)
Third Way 2,1(steps)
So the no of ways are= 3
INPUT You have to take No. of staircases as an input. Where No. (0<=N<=100).
OUTPUT You have to print the No. of Possible ways.
Sample Input:
6
4
3
Sample Output
13
5
3
 
Physics news on Phys.org
No, believe it or not, I do not have to write a program for him! Perhaps you do and, if you get started on it, someone here might make suggestions how to improve your program.
 
Back
Top