当前位置:网站首页>js输出1-100之间所有的质数并求总个数
js输出1-100之间所有的质数并求总个数
2022-06-27 07:20:00 【I am the sun?】
代码如下:
<!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 />质数一共有:" + sum + " 个。");
</script>
</head>
<body>
</body>
</html>
运行结果如下:
边栏推荐
- JDBC operation MySQL example
- JDBC事务提交事例
- Interviewer: you use Lombok every day. What is its principle? I can't answer
- 使用 Blackbox Exporter 测试网络连通性
- Installation and functions of uview
- [Kevin's third play in a row] is rust really slower than C? Further analyze queen micro assessment
- Bean copy details
- Configuring FTP, enterprise official website, database and other methods for ECS
- poi导出excle
- Delay queue `delayqueue`
猜你喜欢

面试官:请你介绍一下缓存穿透、缓存空值、缓存雪崩、缓存击穿的,通俗易懂
![[Software Engineering] software engineering review outline of Shandong University](/img/38/2c783df56b50dee3bbb908f6f3e70e.png)
[Software Engineering] software engineering review outline of Shandong University

Oppo interview sorting, real eight part essay, abusing the interviewer

再见了,敏捷Scrum

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

Gérer 1000 serveurs par personne? Cet outil d'automatisation o & M doit être maîtrisé

yarn create vite 报错 ‘D:\Program‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件

win10远程连接云服务器

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

程序人生 - 程序员三十五岁瓶颈你怎么看?
随机推荐
JDBC操作Mysql示例
1-4 进制表示与转换
guava 教程收集一些案例慢慢写 google工具类
R language calculates Spearman correlation coefficient in parallel to speed up the construction of co occurrence network
使用 Blackbox Exporter 测试网络连通性
Rust Async: smol源码分析-Executor篇
Yarn create vite reports an error 'd:\program' which is neither an internal or external command nor a runnable program or batch file
hutool对称加密
大学数据库mysql
如何优雅的写 Controller 层代码?
Centos7.9 install MySQL 5.7 and set startup
磁选机是什么?
语音信号特征提取流程:输入语音信号-分帧、预加重、加窗、FFT->STFT谱(包括幅度、相位)-对复数取平方值->幅度谱-Mel滤波->梅尔谱-取对数->对数梅尔谱-DCT->FBank->MFCC
uview的安装和功能
jupyter notebook文件目录
vs怎么配置OpenCV?2022vs配置OpenCV详解(多图)
What is the difference between volatile and synchronized?
Sword finger offer 07 Rebuild binary tree
2022 cisp-pte (II) SQL injection
Oppo interview sorting, real eight part essay, abusing the interviewer