Sum All Primes
来源:互联网 发布:淘宝助理宝贝描述红叉 编辑:程序博客网 时间:2024/06/06 17:01
求小于等于给定数值的质数之和。
只有 1 和它本身两个约数的数叫质数。例如,2 是质数,因为它只能被 1 和 2 整除。1 不是质数,因为它只能被自身整除。
给定的数不一定是质数。
function sumPrimes(num) { var sum=0; for (var i = 2; i <= num; i++) { var isPrimes=true; for(var j=2;j<=Math.sqrt(i);j++){ if(i%j===0){ isPrimes=false; break; } } if(isPrimes) sum+=i; }return sum;}sumPrimes(10);
阅读全文
0 0
- Sum All Primes
- Sum All Primes
- Find All Primes
- Problem 10 of Find the sum of all the primes below two million.
- Sum of Consecutive Primes
- Sum of Different Primes
- Sum of Consecutive Primes
- 1259. Sum of Consecutive Primes
- UVa1213 Sum of Different Primes
- sicily1259 Sum of Consecutive Primes
- poj3132 Sum of Different Primes
- <OJ_Sicily>Sum of Consecutive Primes
- poj3132 Sum of Different Primes
- Sum of Different Primes UVA
- WOJ1274-Sum of Different Primes
- Sum of Different Primes UVA
- POJ 3132 Sum of Different Primes
- Sicily 1259. Sum of Consecutive Primes
- Html5调用手机相机并压缩、上传
- 只有挣扎的现在,才是最好的状态(转)(文/王文华)
- 基于tensorflow的视觉问答系统构建
- 如何解决Oracle ASM故障导致的数据丢失问题
- java ajax等传值中文乱码
- Sum All Primes
- 使用vue+elementUI编写运营活动生成工具
- 关于HttpURLConnection的用法
- MySQL基本配置及问题
- 高并发-多线程的使用
- 微软官方的SQLHelper类(含完整中文注释)
- Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available au
- MySQL 处理海量数据时的SQL语句调优
- android开发仿照第三方app打开方式,如何将你的app显示在打开列表,并且将文件复制到你的app应用内