package com.example.practice;
//传入4个值分别为start,end,num1和num2,计算[start,end]之间能被num1整除,但不能被num2整除的数字,并统计个数
public class Test7 {
public static void main(String[] args) {
cal(0,200,7,4,5);
}
public static void cal(int start, int end, int num1, int num2, int line) {
int count = 0;
do {
if (start % num1 == 0 && start % num2 != 0) {
count++;
System.out.print(start + "\t");
if (count % line == 0) {
System.out.println(); //换行
}
}
start++;
} while (start < end);
System.out.println("\n总个数:" + count);
}
}
标签:end,num1,num2,int,start,整除
From: https://www.cnblogs.com/faith007/p/17214868.html