当前位置:网站首页>JS example print the number and sum of multiples of all 7 between 1-100

JS example print the number and sum of multiples of all 7 between 1-100

2022-06-27 07:35:00 I am the sun?

Code :

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title> Print 1-100 Between all 7 Number and sum of multiples of </title>
	<script type="text/javascript">
		var sum = 0,count = 0;
		for(var i = 1;i <= 100;i++){
			if(i % 7 == 0){
				console.log(i);
				sum+=i;
				count+=1;
			}
		}
		console.log("7 Number of multiples of :" + count);
		console.log("7 The sum of multiples of :" + sum);
	</script>
</head>
<body>
	
</body>
</html>

Running results :
 Insert picture description here

原网站

版权声明
本文为[I am the sun?]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270720099939.html