What is a problem in this code one test case are pass another test case are wrong

import java.util.*;
public class Main {
static int answer(int n,int m)
{ int count[]=new int[n+1];
for(int i=1;i<=n;i++) {
if(i>m) {
count[i]=count[i-1]+count[i-m];
}else if(i<m) {
count[i]=1;
}else {
count[i]=2;
}
}
return count[n]%1000000007;
}
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
int t=sc.nextInt();
while(t!=0) {
int n=sc.nextInt();
int m=sc.nextInt();
System.out.println(answer(n,m));
t–; }

}

}

@sksumitkumardiwaker,
https://ide.codingblocks.com/s/225540 corrected code
use long instead of int. And initialize count[0] as 1. Also, do mod at the end of every iteration to count[i]

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.