Tilling- II problem (can't find what is wrong with my code)

import java.util.*;
public class Main {
public static void countWays(int n, int m) {
int[] count = new int[n + 1];
count[0] = 0;
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;
		}

	}

	System.out.println(count[n]);
}

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();
		countWays(n, m);
		t--;
	}
}

}

@10vaibhavsinghnegi,

Corrected code.
Errors:

  1. You need to use long.
  2. Take mod by 10^9+7
  3. Initialize count[0] as 1 not 0.

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.