package com.sgg.test;
public class ZhiShu {
public static void main(String[] args) {
// 第一种方法
/*
for(int i = 2; i<=100;i++){
int j=0;
for(j =2;j<= Math.sqrt(i);j++){
if(i%j==0){
break;
}
}
if(j>Math.sqrt(i)){
System.out.println(i);
}
}
*/
// 第二种方法
/*long start = System.currentTimeMillis();
for(int i = 2;i<=10000;i++){
boolean a = true;
for(int j = 2;j<i;j++){
if(i%j==0){
a = false;
}
}
if(a){
System.out.println(i);
}
}
long end = System.currentTimeMillis();
System.out.println(end-start);*/
// 第三种方法
long start = System.currentTimeMillis();
lable:for(int i=2;i<=100;i++){
for(int j =2;j<=Math.sqrt(i);j++){
if(i%j==0){
continue lable;
}
}
System.out.println(i);
}
long end = System.currentTimeMillis();
System.out.println(end-start);
}
}
11-30
586
04-27
5959
05-14
7万+