zoukankan      html  css  js  c++  java
  • 大三学长带我学习JAVA.作业8。 判断101200之间有多少个素数,并输出所有素数。

    2013年1月19日星期六

    判断101-200之间有多少个素数,并输出所有素数。

    public class Zhouhai {

    public class Zhouhai {

        public static void main(String[] args) {

          

               int i ;

                  for(int n = 101; n <= 200; n++) {

                 

                     int k = (int)Math.sqrt(n);

                 

                     for( i = 2; i <= k; i++ )

                        if( n % i == 0)

                            break;

                                 

                     if(i >= k + 1)

                           System.out.printf(n + "  ");

                 

                  }

           }    

                    

    }

  • 相关阅读:
    docker学习
    获取程序所有加载的dll名称
    Microsoft.Exchange 发邮件
    EF实体对象解耦
    python并发与futures模块
    python协程
    python上下文管理器
    python迭代器与生成器
    python抽象基类
    python运算符重载
  • 原文地址:https://www.cnblogs.com/shaoshao/p/2867548.html
Copyright © 2011-2022 走看看