publicclassExample1{/***@paramargs*/publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubintb=2;//i即所求素数intcount=0;System.out.println("b="+b);for(b=3;b<=...
public class Example1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int b=2; //i 即所求素数
int count=0;
System.out.println("b= " +b);
for(b=3; b<=100;b=b+2)
{
boolean f = true;
for(int j=2;j
{
if(b%j==0)
{
f=false;
break;
}
}
if(f)
{
count++;
System.out.println("b= " +b);
}
System.out.println("count="+count);
}
}
}
public class Text5 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i=101; //i 即所求素数
int count=0;
System.out.println("i= " +i);
for(i=103; i<=599; i=i+2)
{
boolean f = true;
for(int j=2;j
{
if(i%j==0)
{
f=false;
break;
}
}
if(f)
{
count++;
System.out.println("i= " +i);
}
System.out.println("count="+count);
}
}
}
展开