-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab3_1.java
More file actions
57 lines (39 loc) · 1.06 KB
/
Lab3_1.java
File metadata and controls
57 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.util.Arrays;
import java.util.Scanner;
public class Lab3_1 {
public static void main(String[] args) {
int line = 0;
for (int i = 0; line < 100; i++) {
if (Prime(i) && Palin(i)) {
System.out.print(i + " ");
line++;
if (line % 10 == 0 && i != 0) {
System.out.println();
}
}
}
}
public static boolean Prime(int number) {
if (number < 2) {
return false;
}
for (int i = 2; i <= number / 2; i++) {
if (number % i == 0) {
return false;
}
}
return true;
}
public static int trans(int number) {
int trans = 0;
while (number != 0) {
trans *= 10;
trans += number % 10;
number /= 10;
}
return trans;
}
public static boolean Palin(int number) {
return (number == trans(number));
}
}