- public class Test {
- public static int is_sushu(int n) {
- if(n == 1) {
- return 0;
- }
- int i ;
- for (i = 2; i <= Math.sqrt(n); i++) {
- if(n % i == 0 ) {
- break;
- }
- }
- if (i > n) {
- return 1;
- }
- return 0;
- }
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = scanner.nextInt();
- int ret = is_sushu(n);
- if(ret == 1 ) {
- System.out.println(n + "是素数");
- } else {
- System.out.println(n + "不是素数");
- }
- }
- }
- public class Test {
- public static void main(String[] args) {
- int year ;
- for ( year = 1000; year <= 2000 ; year++) {
- if(year % 4 ==0 && year % 100 !=0 || year % 400 == 0 )
- {
- System.out.println(year + "是闰年");
- }
- }
- }
- }
- public class Test {
- public static void main(String[] args) {
- for (int i = 1; i <= 9; i++) {
- for (int j = 1; j <= i ; j++) {
- System.out.print(i + "*" + j + "=" + i*j + " ");
- }
- System.out.println();
- }
- }
- }
- public class Test {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int a = scanner.nextInt();
- int b = scanner.nextInt();
- if(b > a) {
- int tmp = b;
- b = a;
- a = b;
- }
- int c =a % b;
- while(c != 0) {
- a = b;
- b = c;
- c = a % b;
- }
- System.out.println(b);
- }
- }
- public class Test {
- public static void main(String[] args) {
- int i;
- for (i = 100; i < 1000 ; i++) {
- int k = i;
- int sum = 0;
- while(k != 0) {
- sum+=Math.pow(k%10,3);
- k /= 10;
- }
- if (sum == i) {
- System.out.println(i);
- }
- }
- }
- }
..0