当前位置:网站首页>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 :
边栏推荐
- Goodbye, agile Scrum
- Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
- 将通讯录功能设置为数据库维护,增加用户名和密码
- log4j:WARN No such property [zipPermission] in org. apache. log4j. RollingFileAppender.
- Speech synthesis: tacotron explains [end-to-end speech synthesis model] [compared with traditional speech synthesis, it does not have complex phonetics and acoustic feature modules, but only uses < te
- Bean copy details
- js例题打印1-100之间所有7的倍数的个数及总和
- log4j:WARN No such property [zipPermission] in org.apache.log4j.RollingFileAppender.
- Custom palette for ggplot2
- File and multipartfile overview
猜你喜欢
Yarn create vite reports an error 'd:\program' which is neither an internal or external command nor a runnable program or batch file
Memory barrier store buffer, invalid queue
用XGBoost迭代读取数据集
cookie加密7 fidder分析阶段
JS use switch to output whether the result is qualified
log4j:WARN No such property [zipPermission] in org. apache. log4j. RollingFileAppender.
File and multipartfile overview
多表联查--07--- Hash join
Configuring FTP, enterprise official website, database and other methods for ECS
Vs how to configure opencv? 2022vs configuration opencv details (multiple pictures)
随机推荐
Custom palette for ggplot2
JDBC operation MySQL example
Speech signal processing - concept (I): time spectrum (horizontal axis: time; vertical axis: amplitude), spectrum (horizontal axis: frequency; vertical axis: amplitude) -- Fourier transform -- > time
What is a magnetic separator?
基础知识 | js基础
Speech signal processing - concept (II): amplitude spectrum (STFT spectrum), Mel spectrum [the deep learning of speech mainly uses amplitude spectrum and Mel spectrum] [extracted with librosa or torch
Common operation and Principle Exploration of stream
R language calculates Spearman correlation coefficient in parallel to speed up the construction of co occurrence network
JDBC事务提交事例
1-4 进制表示与转换
Bean拷贝详解
Nature、science、cell旗下刊物
请问如何将数据从oracle导入fastDFS?
Speech synthesis: tacotron explains [end-to-end speech synthesis model] [compared with traditional speech synthesis, it does not have complex phonetics and acoustic feature modules, but only uses < te
js来打印1-100间的质数并求总个数优化版
Bean copy details
多表联查--07--- Hash join
Hutool symmetric encryption
Cookie encryption 7 fidder analysis phase
Coggle 30 Days of ML 7月竞赛学习