日期:2014-05-20 浏览次数:20779 次
package study.problem.second;
public class promble_2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int n=100;
for (int i=3;i<=n;i++)
{
double sqrti;
sqrti=Math.sqrt(i);
for (int j=2;j<=sqrti;j++)
{
int w=0;
if (i%j==0)
{
System.out.println(i+"is not a Prime ");
break;
}
else
{
}
}
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int n = 100;
for (int i = 3; i <= n; i++) {
double sqrti;
sqrti = Math.sqrt(i);
boolean w = true;
for (int j = 2; j <= sqrti; j++) {
w = true;
if (i % j == 0) {
System.out.println(i + " is not a Prime.");
w = false;
break;
}
}
if(w){
System.out.println(i + " is a Prime!!!");
}
}
}