思路:将当前条目数算出当前处于哪个区间范围内,然后判断当前条目是否已经到了区间范围内的触发起始数
public static void main(String[] args) {
/* 当前条目数 */
int currentCount = 0;
/* 逢 */
int x = 3;
/* 扣 */
int n = 1;
if(isDivisible(currentCount,x)){
System.out.println("该条目需要扣除");
return;
}
/* 最大范围 */
int max = ((currentCount / x) + 1) * x;
/* 最小范围 */
int min = max - x;
/* 起始触发数 */
int begin = max - n;
if (currentCount > begin) {
System.out.println("该条目需要扣除");
return;
}
}
/**
* 判断m是否能被n整除
*
* @param m 被除数
* @param n 除数
* @return
*/
private boolean isDivisible(int m, int n) {
if (m % n == 0) {
return true;
}
return false;
}