当前位置:网站首页>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;
边栏推荐
- Uipath practice (08) - selector
- 论文阅读_ICD编码_MSMN
- Objects. Requirenonnull method description
- 1106 lowest price in supply chain (25 points)
- Notes | numpy-07 Slice and index
- On typescript and grammar
- [research materials] 2022q1 game preferred casual game distribution circular - Download attached
- My first Smartphone
- Learn to use the idea breakpoint debugging tool
- 1103 integer factorization (30 points)
猜你喜欢

Celebrate the new year together

Thesis reading_ ICD code_ MSMN

2022-02-11 daily clock in: problem fine brush

Kept hot standby and haproxy
![[USACO 2009 Dec S]Music Notes](/img/e6/282a8820becdd24d63dcff1b81fcaf.jpg)
[USACO 2009 Dec S]Music Notes

5-36v input automatic voltage rise and fall PD fast charging scheme drawing 30W low-cost chip

Handling record of electric skateboard detained by traffic police

leetcode452. Detonate the balloon with the minimum number of arrows

LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)

Shallow and first code
随机推荐
"Pthread.h" not found problem encountered in compiling GCC
M1 Pro install redis
1118 birds in forest (25 points)
Based on RFC 3986 (unified resource descriptor (URI): general syntax)
sql语句模糊查询遇到的问题
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
Flutter monitors volume to realize waveform visualization of audio
Distinguish between releases and snapshots in nexus private library
Shuttle + Alluxio 加速内存Shuffle起飞
Market status and development prospect prediction of the global forward fluorescent microscope industry in 2022
Actual combat 8051 drives 8-bit nixie tube
论文阅读_中文医疗模型_ eHealth
Market status and development prospect prediction of global fermented plant protein industry in 2022
[tools run SQL blind note]
1094 the largest generation (25 points)
[set theory] binary relation (example of binary relation operation | example of inverse operation | example of composite operation | example of limiting operation | example of image operation)
Basic knowledge of reflection (detailed explanation)
Hire cashier (differential constraint)
Gbase8s unique index and non unique index
JDBC database operation