java打印1000内的质数并用表格输出

<table width='500' border='1'>
<%
int c=1;
for(int i=2;i<=1000;i++){
int n=0;
for(int j=2;j<i;j++){
if(i%j==0){
n++;
break;
}
}
if(n==0){
if(c%10==0){  
out.println("<td>"+i+"</td>");
out.println("<tr>");
c++;
}else{
out.println("<td>"+i+"</td>");
c++;
}
}
}
%>
</table>

效果如下:

猜你喜欢

转载自www.cnblogs.com/zym2000/p/9149720.html