码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-03-24 00:38:41      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:情况   print   void   system   blog   素数   company   style   nbsp   

 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 }

 

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

标签:情况   print   void   system   blog   素数   company   style   nbsp   

原文地址:https://www.cnblogs.com/nhm292/p/8635595.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!