计算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>

posted @ 2021-03-04 17:13  拾掇拾掇  阅读(175)  评论(0编辑  收藏  举报