打印1~100之间所有的7的倍数的个数及总和

230 阅读1分钟


<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			var num = 0//count:计数器
            count = 0;
			for(n = 1 ; n <= 100 ; n++){
				if(n%7 == 0){
					num = num + n;
					count++;
				}
			}
			alert("num = " + num);
			alert("个数 = " + count);
		</script>
	</head>
	<body>
	</body>
</html>