class sushu
{
public static void main(String[] args)
{
int a=5;
shu(a);
}
public static int shu(int num)
{
int i;
int count=0;
for(i=2;i<sqrt(num);i++)
{
if(num/i==0)
{
return 0;
System.out.println(num+"不是素数");
}
else
{
return 1;
count ++;
System.out.println(num+"是素数!");
}
}
System.out.println("共有"+count+"个素数!");
}
}
|
|