计算1-100中的素数之和
代码:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body> This is my JSP page. <br> </body> <% int i, j, sum = 0; for (i = 1; i < 100; i++) { for (j = 2; j < i; j++) { if (i % j == 0) { break; } } if (j == i) { sum += i; } } %> <%=sum%> </html>