当前位置:网站首页>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 :
边栏推荐
- Window right click management
- R 语言Analyzing wine data
- Interviewer: you use Lombok every day. What is its principle? I can't answer
- Coal crusher
- Sword finger offer 07 Rebuild binary tree
- C# 请问怎么在更新数据库时候调用line与rows
- 碎煤机crusher
- cookie加密7 fidder分析阶段
- How to download opencv? How to configure opencv after downloading?
- Xiaomi Interviewer: let's talk about the proficient Registration Center for three days and three nights
猜你喜欢

js用switch语句根据1-7输出对应英文星期几

Solve the problem of win10 wsl2 IP change

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

MySQL

(已解决) MINet 进行测试时报错如下 raise NotImplementedError

【软件工程】山东大学软件工程复习提纲

Basic knowledge | JS Foundation

Interviewer: how to never migrate data and avoid hot issues by using sub database and sub table?

Cookie encryption 7 fidder analysis phase

Cookie加密6
随机推荐
在线文本数字识别列表求和工具
One person manages 1000 servers? This automatic operation and maintenance tool must be mastered
Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
oracle的similarity方法实现原理
Rust Async: smol源码分析-Executor篇
sql sever列名或所提供值的数目与表定义不匹配
yarn create vite 报错 ‘D:\Program‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件
Delay queue `delayqueue`
How to implement redis cache of highly paid programmers & interview questions series 116? How do I find a hot key? What are the possible problems with caching?
How to write controller layer code gracefully?
window右键管理
请问网页按钮怎么绑定sql语句呀
JDBC reads MySQL data list
SQL考勤查询间隔一小时
Visual studio vs shortcut key usage
一個人管理1000臺服務器?這款自動化運維工具一定要掌握
MySQL
Get the query parameter in the address URL specify the parameter method
js来打印1-100间的质数并求总个数优化版
Gérer 1000 serveurs par personne? Cet outil d'automatisation o & M doit être maîtrisé