当前位置:网站首页>JS function algorithm interview case
JS function algorithm interview case
2022-07-03 05:04:00 【The wind blows and birds fly in the crotch】
Write a function , It receives a numeric parameter num, The return value is the sum of all prime numbers not greater than this number .
Print all less than 10 The prime number of ( prime number ), And then sum up ( Prime number : Can only be 1 Divide with yourself )
Problem solving :
function name(num) {
// var arr = 0;
// for (i = 2; i <= num; i++) {// although 1 It also meets the characteristics of prime numbers , however 1 Is a special number , So from 2 Start the cycle
// for (j = 2; j <= i; j++) {
// if (i % j == 0) {
// break;
// }
// }
// if (j == i) {
// arr += i;
console.log(i);
// }
// }
// console.log(arr);
// }
// name(10);
All less than 10 The prime number of ( prime number ) by 2,3,5,7;
All less than 10 The prime number of ( prime number ) The result of the sum of is 17;
边栏推荐
- Handling record of electric skateboard detained by traffic police
- document. The problem of missing parameters of referer is solved
- C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
- ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation
- Market status and development prospect forecast of global button dropper industry in 2022
- 第十九届浙江省 I. Barbecue
- cookie session jwt
- M1 Pro install redis
- 1103 integer factorization (30 points)
- Basic knowledge of reflection (detailed explanation)
猜你喜欢

How to connect the network: Chapter 2 (Part 1): a life cycle of TCP connection | CSDN creation punch in
![[research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached](/img/01/052928e7f20ca671cdc4c30ae55258.jpg)
[research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached

论文阅读_中文NLP_ELECTRA

The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article

Thesis reading_ Chinese NLP_ ELECTRA

JS dynamic table creation

leetcode435. Non overlapping interval

Shuttle + alluxio accelerated memory shuffle take-off

I stepped on a foundation pit today

【批处理DOS-CMD命令-汇总和小结】-CMD窗口的设置与操作命令-关闭cmd窗口、退出cmd环境(exit、exit /b、goto :eof)
随机推荐
[research materials] annual report of China's pension market in 2021 - Download attached
1087 all roads lead to Rome (30 points)
Shallow and first code
1103 integer factorization (30 points)
Sprintf formatter abnormal exit problem
Notes | numpy-09 Broadcast
最大连续子段和(动态规划,递归,递推)
Gbase8s composite index (I)
sql语句模糊查询遇到的问题
Review the old and know the new: Notes on Data Science
Shuttle + alluxio accelerated memory shuffle take-off
leetcode860. Lemonade change
MediaTek 2023 IC written examination approved in advance (topic)
Mobile terminal - uniapp development record (public request encapsulation)
RT thread flow notes I startup, schedule, thread
Market status and development prospect prediction of global colorimetric cup cover industry in 2022
[luatos sensor] 1 light sensing bh1750
Gbase8s unique index and non unique index
First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
Objects. Requirenonnull method description