Use JSP to print all prime numbers within 1000 of a table on a browser

Source: Internet
Author: User

<table width= "80%" border= "1" align= "Center" >

<%
Calc Calc = new Calc (); New A Calc Class
int n = 0; Mark a column tag
for (int i = 1; i <=; i++) {//number within loop 1000
Calc.setvalue (i); Assigns a value within 1000 to the value in the Calc class
if (Calc.isprime ()) {//calls the IsPrime method in the Calc class, this method is used to determine whether a prime number
n++; //
if (n% 5 = = 1) {//use modulo to calculate if each column has a value
Out.print ("<tr>"); Typing a column label with HTML tags
}
%>
<td><%=i%></td><!--Output Value-->>

<%
if (n% 5 = = 0) {//use modulo to calculate if each column has a value
Out.print ("</tr>"); Typing a column label with HTML tags
}
}
}

if (n% 5 = = 1) {//use modulo to calculate if each column has a value
Out.print ("<td></td><td></td><td></td><td></td></tr>"); If only one value hits 4 blank cells
} else if (n 5 = = 2) {//use modulo to calculate if each column has a value
Out.print ("<td></td><td></td><td></td></tr>"); If only two values hit 3 blank cells
} else if (n 5 = = 3) {//use modulo to calculate if each column has a value
Out.print ("<td></td><td></td></tr>"); If only three values hit 2 blank cells
} else if (n 5 = = 4) {//use modulo to calculate if each column has a value
Out.print ("<td></td></tr>"); If only four values hit 1 blank cells
} else if (n 5 = = 5) {//use modulo to calculate if each column has a value
Out.print ("</tr>"); If only no value hit the direct End column label
}
%>

</table>

Use JSP to print all prime numbers within 1000 of a table on a browser

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.