
Asked in ION Group
Count Ways to Climb Stairs Problem
Given a staircase with a certain number of steps, you start at the 0th step, and your goal is to reach the Nth step. At every step, you have the option to move either one step or two steps up the stairs. Your task is to determine the number of distinct ways to reach the Nth step from the 0th step.
Input:
The input consists of multiple test cases.
The first line of the input:
T
represents the number of test cases.
For each test case:
N
represents the number of stairs.
Output:
For each test case, output the number of distinct ways to reach the top of the stairs. Since the result can be very large, return the result modulo 10^9+7.
Example:
Input:
3
2
3
4
Output:
2
3
5
Explanation:
For N=3: You can reach the 3rd step by {(0,1,2,3)}, {(0,2,3)}, or {(0,1,3)}. So, there are 3 distinct ways to climb.
Constraints:
1 ≤ T ≤ 100
0 ≤ N ≤ 1018
Note:
You are not required to print anything; it has already been handled. Just implement the function and return the answer.
Top Software Developer Interview Questions Asked at ION Group
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for ION Group Software Developer


Reviews
Interviews
Salaries
Users

