import java.util.Scanner; import java.util.ArrayList; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<Integer> array = new ArrayList<Integer>(); for (int i = 100; i <= 999; i++) { for (int j = 1; j <= i; j++) { if (i % j == 0 && j != 1 && j != i) { array.add(i); break; } } } System.out.println(900-array.size()); } }
public class Main{ public static void main(String[] args){ int count=0; for(int i=100;i<1000;i++){ if(isPrime(i)) count++; } System.out.println(count); } public static boolean isPrime(int x){ boolean is=true; for(int i=x-1;i>1;i--){ if(x%i==0){ is=false; break; } } return is; } }
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int count = 0; //while(scanner.hasNext()){ for(int i = 100;i <= 999;i++){ for(int j = 2 ; j < i ;j++){ if(i % j == 0){ count++; break; } } } System.out.println(900 - count); //} } }
public class Main{ public static void main (String[] args){ int x=0; for(int i=100;i<=999;i++){ int j=2; while(i%j!=0){ j++; if(i==j){ x++; } } } System.out.println(x); } }
import java.util.*; public class Main { public static void main(String [] args) { int count=0; for(int i=100;i<=999;i++) { if(isZhiShu(i)) { count++; } } System.out.println(count); } public static boolean isZhiShu(int num) { for(int i=2;i<num;i++) { if(num%i==0)//如果找到一个反例,说明不是质数 { return false; } } return true; } }