当前位置:网站首页>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>
边栏推荐
- 改哭了,终于解决了Cannot read properties of undefined (reading ‘parseComponent‘)
- 完全去中心化的编程模式,不需要服务器,也不需要ip,就像一张漫无目的的网络、四处延伸
- 量化开发必掌握的30个知识点【什么是分笔逐笔数据】?
- Laravel Swagger添加访问密码
- Sliding switch of tab of uniapp component
- Fvuln automated web vulnerability detection tool
- What is wapiti and how to use it
- Relative positioning and absolute positioning
- Wechat applet - component parameter transmission, state management
- MOVE PROTOCOL全球健康宣言,将健康运动进行到底
猜你喜欢

解决表单校验提示信息不消失问题以及赋值不生效问题

table中同一列中合并相同项

Wapiti是什么以及使用教程

Hcia-r & s self use notes (25) NAT technical background, NAT type and configuration

Crypto giants all in metauniverse, and platofarm may break through

QPalette学习笔记

Solve the problem that the prompt information of form verification does not disappear and the assignment does not take effect

Masscan使用教程.

Installation steps and environment configuration of vs Code

Fvuln automated web vulnerability detection tool
随机推荐
Hcia-r & s self use notes (25) NAT technical background, NAT type and configuration
Hcia-r & s self use notes (24) ACL
Elastic box flex
Mobile terminal -flex item attribute
第五空间智能安全⼤赛真题----------PNG图⽚转换器
如何在加密市场熊市中生存?
[typescript] learn typescript object types in depth
Laravel服务容器(上下文绑定的运用)
PHP如何生成二维码?
“山东大学移动互联网开发技术教学网站建设”项目实训日志七
Qframe class learning notes
Hcia-r & s self use notes (27) comprehensive experiment
php写一个购买全网最低价的纸尿裤
Fantom (FTM) 在 FOMC会议之前飙升 45%
Masscan tutorial
获取水仙花数
Go|Gin 快速使用Swagger
The Platonic metauniverse advocated by musk has long been verified by platofarm
How to survive in the bear market of encryption market?
Sliding switch of tab of uniapp component