当前位置:网站首页>Print out all prime numbers between 1-100
Print out all prime numbers between 1-100
2022-07-29 05:47:00 【Just learning records】
Print out 1-100 All prime numbers between
1、 find 1-100 All the numbers between
2、 Judge whether it is prime
3、 Print out the prime number found
<script type="text/javascript">
/**
* 2、 Print out 1-100 All prime numbers between
* ( Prime number : except 1 And outside of himself , Numbers that cannot be divided by other numbers are called prime numbers )
* We know 1 It's neither prime nor sum , So the following code directly from 2 Start
*/
// Print 2-100 All the numbers between
for(var i=2;i<=100;i++){
var flag=true;
// Judge i Is it a prime number , obtain 2-i All the numbers between
for(var j=2;j<i;j++){
// Judge i If I can be j to be divisible by
if(i%j == 0){
// If you enter the judgment, it will prove i Not prime , modify flag The value of is false
flag=false;
}
}
if(flag){
document.write(i+" ");
}
}
</script>
边栏推荐
- Liang Yuqi, founder of aitalk: the link between image and virtual reality
- 闪贷Dapp的调研及实现
- MOVE PROTOCOL全球健康宣言,将健康运动进行到底
- Plato Farm有望通过Elephant Swap,进一步向外拓展生态
- DAO赛道异军突起,M-DAO的优势在哪里?
- Crypto巨头们ALL IN元宇宙,PlatoFarm或能突围
- Go|Gin 快速使用Swagger
- 运动健康深入人心,MOVE PROTOCOL引领品质生活
- Wechat applet - screen height
- OpenAtom OpenHarmony分论坛圆满举办,生态与产业发展迈向新征程
猜你喜欢

马斯克推崇的柏拉图式元宇宙,PlatoFarm早已验证出答案

Liang Yuqi, founder of aitalk: the link between image and virtual reality

Common prompt pop-up box of uniapp

The Platonic metauniverse advocated by musk has long been verified by platofarm

山寨币SHIB 在 ETH 鲸鱼的投资组合中拥有 5.486 亿美元的股份——交易者应提防……

php写一个购买全网最低价的纸尿裤

Wechat applet - screen height

sql-server 数据表的简单操作

Plato farm is expected to further expand its ecosystem through elephant swap

Sports health is deeply rooted in the hearts of the people, and move protocol leads quality life
随机推荐
Relationship between link and @import
Day14: upload labs customs clearance tutorial
Hcia-r & s self use notes (25) NAT technical background, NAT type and configuration
“山东大学移动互联网开发技术教学网站建设”项目实训日志五
改哭了,终于解决了Cannot read properties of undefined (reading ‘parseComponent‘)
Win10 搭建MSYS2环境
Sqlmap是什么以及使用方法
dcat 批量操作弹窗及参数传递
[typescript] learn typescript object types in depth
The LAAS protocol of defi 2.0 is the key to revitalizing the development of defi track
Seay source code audit system
Set the background color of a cell in the table
Build msys2 environment with win10
What is sqlmap and how to use it
Similarities and differences between REM and PX and EM
使用Qss设置窗体样式
Mobile terminal -flex item attribute
php写一个购买全网最低价的纸尿裤
QFrame类学习笔记
DAY6:利用 PHP 编写登陆页面