taosheng-yijiu

*因为1既不是质素也不是素数,所以从2开始*

下面给出了一种简单的方法:

public class ceshi{

  public static void main(String[] args){

    int j;

    for(int i=2; i <= 100; i++ ) {

      for( j = 2; j <= i; j++ ) {

        if( i % j == 0 ) {

          break;

        }

      }

      if( j >= i ) {

        System.out.println(i);

      }

    } 

  } 

}

分类:

技术点:

相关文章:

  • 2021-10-21
  • 2021-11-12
  • 2021-10-21
  • 2021-10-21
  • 2021-10-21
  • 2021-10-21
  • 2020-06-05
  • 2021-10-21
猜你喜欢
  • 2021-10-21
  • 2021-10-21
  • 2021-10-21
  • 2021-11-12
  • 2021-10-21
  • 2021-10-21
  • 2021-10-21
相关资源
相似解决方案