publicclassA1{publicstaticvoidmain(String[] args){for(int k =101; k <=205; k++){boolean res =true;for(int i =2; i < k /2; i++){if(k % i ==0){
res =false;break;}}if(res)
System.out.println(k +"是质数");// else// System.out.println(k + "不是质数");}}}
2.输入两个正整数m和n,求其最大公约数和最小公倍数?
publicclassA2{publicstaticvoidmain(String[] args){int k1 =11, k2 =15;int min = k1 > k2 ? k2 : k1;for(int i = min; i >=1; i--){if(k1 % i ==0&& k2 % i ==0){
System.out.println(k1 +"和"+ k2 +"的最大公约数为"+ i);break;}}int k1 =3, k2 =6;int begin = Math.max(k1, k2);int end = k1 * k2;for(int i=begin;i<=end;i++){if(i%k1==0&& i%k2==0){
System.out.println(k1+"和"+k2+"的最小公倍数为:"+i);break;}}
1.求出自然数101-205中的所有质数?public class A1 { public static void main(String[] args) { for (int k = 101; k <= 205; k++) { boolean res = true; for (int i = 2; i < k / 2; i++) { if (k % i == 0) { res = false; break; } } if (res) System.out.println