Select Git revision
DashboardFragment.java
-
Shubham Maheshwari authoredShubham Maheshwari authored
lab3-q4.py 581 B
"""
There are n stairs, a person standing at the bottom wants to reach the top. The person
can climb either 1 stair or 2 stairs at a time. Count the number of ways, the person can
reach the top.
Consider the example shown in diagram. The value of n is 3. There are 3 ways to reach
the top.
o steps - 1 way
1 step - 1 way
2 steps - 2 ways
"""
def climb(steps):
if(steps <= 1):
return 1;
elif(steps == 2):
return 2;
else:
return climb(steps-1) + climb(steps-2)
ip = int(input("enter number of steps : "))
print(climb(ip))