importjava.util.Scanner;publicclassTest{// 判断n是否为质数publicstaticbooleanisPrime(int n){if(n <2)returnfalse;for(int i =2; i < n; i++){if(n % i ==0)returnfalse;}returntrue;}publicstaticvoidmain(String[] args){Scanner scanner =newScanner(System.in);System.out.print("请输入一个整数:");int n = scanner.nextInt();scanner.close();for(int i =2; i < n; i++){if(isPrime(i)){// i是质数System.out.print(i +" ");}}}}