JAVA编程-------------27、100以内的素数

 1 package FushiExam;
 2 
 3 public class Text_27 {
 4 
 5     public static void main(String[] args) {
 6         // 求100以内的素数
 7         System.out.println("输出100以内的素数:");
 8         for(int i=2;i<=100;i++) {
 9             int tage=0;
10             for(int j=2;j<=Math.sqrt(i);j++) {
11                 if(i%j==0)
12                     tage=1;
13             }
14             if(tage==0)
15                 System.out.println(i);
16         }
17 
18     }
19 
20 }

猜你喜欢

转载自www.cnblogs.com/fmust/p/12508744.html
今日推荐