编写JSP页面,计算1-100之间的所有素数之和
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>$Title$</title> </head> <body> 1-100素数的和为: <% int i; int sum = 0; boolean flag = true; for (i = 2; i <= 100; i++) { flag = true; for (int j = 2; j < i; j++) { if (i % j == 0) { flag = false; break; } } if (flag) { sum += i; } } %> <%=sum %> </body> </html>