当前位置:网站首页>JS output all prime numbers between 1-100 and calculate the total number
JS output all prime numbers between 1-100 and calculate the total number
2022-06-27 07:35:00 【I am the sun?】
The code is as follows :
<!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>Document</title>
<script type="text/javascript">
var sum = 0;
for(var i = 1;i <= 100;i++){
var flag = true;
if(i == 1)
flag = false;
for(var j = 2;j < i;j++){
if(i % j == 0){
flag = false;
break;
}
}
if(flag){
document.write(i + " ");
sum++;
}
}
document.write("<br /> Primes in all :" + sum + " individual .");
</script>
</head>
<body>
</body>
</html>
The operation results are as follows :
边栏推荐
- 1-4 进制表示与转换
- The interviewer of a large front-line factory asked: do you really understand e-commerce order development?
- PostgreSQL encounters permission denied in Windows system
- sql sever列名或所提供值的数目与表定义不匹配
- 通过uview让tabbar根据权限显示相应数量的tabbar
- RNA SEQ data analysis in R - investigate differentially expressed genes in the data!
- Error in idea connection database
- From 5 seconds to 1 second, the system flies
- Cookie encryption 6
- jupyter notebook文件目录
猜你喜欢

js中判断成绩是否合格,范围在0-100,否则重新输入

Configuring FTP, enterprise official website, database and other methods for ECS

js成绩奖惩例题

Coggle 30 Days of ML 7月竞赛学习

js来打印1-100间的质数并求总个数优化版

File and multipartfile overview

How to write controller layer code gracefully?

js用while循环计算假如投资多年的利率为5%,试求从1000块增长到5000块,需要花费多少年

JS performance reward and punishment examples

Basic knowledge | JS Foundation
随机推荐
Basic knowledge | JS Foundation
JDBC事务提交事例
How to write controller layer code gracefully?
(resolved) NPM suddenly reports an error cannot find module 'd:\program files\nodejs\node_ modules\npm\bin\npm-cli. js‘
2022 cisp-pte (II) SQL injection
How torch.gather works
Window right click management
mysql关于自增和不能为空
JS use switch to output whether the result is qualified
ggplot2的自定义调色板
Gérer 1000 serveurs par personne? Cet outil d'automatisation o & M doit être maîtrisé
1-4 进制表示与转换
js打印99乘法表
Interviewer: you use Lombok every day. What is its principle? I can't answer
程序人生 - 程序员三十五岁瓶颈你怎么看?
Visual studio vs shortcut key usage
Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
js中输入三个值,并且由小到大输出
通过uview让tabbar根据权限显示相应数量的tabbar
Interviewer: please introduce cache penetration, cache null value, cache avalanche and cache breakdown, which are easy to understand