/**2
* 判斷101-200之間有多少個素數,并輸出這些素數
**/
public class Test{ public static void main(String[] args){ int i, j; for (i = 101; i < 200; i += 2) { for (j = 2; j <= (int)Math.sqrt(i); j++) if (i % j == 0) break; if (j > Math.sqrt(i)) System.out.print(i + " "); } } }
时间: 2024-10-07 18:33:08