Problem related to output

import java.util.*;
public class Main {
public static long bottomToTop(int n, int m) {
long dp[] = new long[n+1];
dp[0] = 1;
for(int i=1; i<=n; i++) {
dp[i] = dp[i-1];
if(i-m>=0) dp[i] += dp[i-m];
}
return dp[n];
}
public static void main(String[] args) {
//System.out.println();
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t–>0) {
int n = sc.nextInt();
int m = sc.nextInt();
//System.out.println(topToBottom(n,m, new long[n+1]));
System.out.println(bottomToTop(n,m));
}

}

}
Test cases are not getting passed for this code. What might be the problem?

You have not taken mod of the Number of ways. Mod it by 10^9+7 as given in the question.

for(int i=1; i<=n; i++) {
dp[i] = dp[i-1];
if(i-m>=0) dp[i] += dp[i-m];
dp[i] %= 1000000007;
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.