java实现查找100~200之间的素数

 1 package com.company;
 2 
 3 public class Main {
 4 
 5     public static void main(String[] args) {
 6     // write your code here
 7         System.out.println("helloworld");
 8         int i;
 9         int j;
10         for (i=100;i<=200;i++){  //循环i=100~200
11             for (j=2;j<i;j++){    //循环j=2~200
12                 if (i % j==0){    //判断i能被j整出的i
13                     break;
14                 }
15             }
16             if (i==j){            //判断在i被j整除的情况下i和j相同的数及为水仙花数
17                 System.out.println(i);
18             }
19         }
20     }
21 }

 

posted @ 2018-03-23 23:10  Import_LL  阅读(1163)  评论(0编辑  收藏  举报