public class A { public static void main(String[] args) { } // 求质数 100以内的 public static void zhishu() { for (int j = 1; j < 100; j++) { int i = 0; for (int j2 = 1; j2 <= j; j2++) { if (j % j2 == 0) { i++; } } if (i == 2) { System.out.println(j + ","); } } } // 求阶乘 public void jiecheng() { int a = 3; int b = 1; /* * for (a = 3; a > 0; a--) { b = b * a; } */ while (a > 0) { b = b * a; a--; } System.out.println(b); A.zhishu(); } }
时间: 2024-10-31 09:32:19