package number;
import java.util.Scanner;
public class Prime {
public static void main(String[] args) {
int i = 0;
System.out.println("1.3-100 2.任意两数 3.最大十个和最小十个");
Scanner sc = new Scanner(System.in);
i = sc.nextInt();
switch (i) {
case 1:
isprime();
break;
case 2:
isprime1();
break;
case 3:
isprime2();
break;
}
} public static void isprime() {
int n;
int i = 2;
int m = 0;
for (n = 3; n >= 3 && n <= 100; n++) {
int j = 0;
if (n % 2 == 0)
j = 1;
for (i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0)
j = 1;
}
if (j == 0) {
m++;
System.out.print(n + "\t");
if (m % 5 == 0)
System.out.println();
}
}
System.out.println();
} public static void isprime1() {
System.out.println("请输入两个整数:");
Scanner sc = new Scanner(System.in);
int num1, num2;
System.out.println("number1:");
num1 = sc.nextInt();
System.out.println("number2:");
num2 = sc.nextInt();
int n;
int i = 2;
int m = 0;
for (n = num1; n >= num1 && n <= num2; n++) {
int j = 0;
if (n % 2 == 0)
j = 1;
for (i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0)
j = 1;
}
if (j == 0) {
m++;
System.out.print(n + "\t");
if (m % 5 == 0)
System.out.println();
}
}
} public static void isprime2() {
Scanner sc = new Scanner(System.in);
System.out.println("请输入两个整数:");
int num1, num2;
System.out.println("number1:");
num1 = sc.nextInt();
System.out.println("number2:");
num2 = sc.nextInt();
System.out.println("十个最小:");
int n;
int i = 2;
int m = 0;
int k = 0;
int a[] = new int[100];
for (n = num1; n >= num1 && n <= num2; n++) {
int j = 0; if (n % 2 == 0)
j = 1;
for (i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0)
j = 1;
}
if (j == 0) {
m++;
a[m] = n;
if (m <= 10)
System.out.print(a[m] + "\t");
}
}
System.out.println();
System.out.println("十个最大:");
for (k = m - 10; k <= m; k++) {
System.out.print(a[k] + "\t");
} }
}