当前位置:网站首页>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;
边栏推荐
- 2022-02-12 daily clock in: problem fine brush
- [research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
- The 19th Zhejiang I. barbecue
- Thesis reading_ Chinese medical model_ eHealth
- cookie session jwt
- Automatic voltage rise and fall 5-40v multi string super capacitor charging chip and solution
- C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
- MPM model and ab pressure test
- 1118 birds in forest (25 points)
- 1114 family property (25 points)
猜你喜欢
On typescript and grammar
论文阅读_ICD编码_MSMN
[batch dos-cmd command - summary and summary] - CMD window setting and operation command - close CMD window and exit CMD environment (exit, exit /b, goto: EOF)
[set theory] relational representation (relational matrix | examples of relational matrix | properties of relational matrix | operations of relational matrix | relational graph | examples of relationa
cookie session jwt
[USACO 2009 Dec S]Music Notes
Source insight garbled code solution
2022-02-11 daily clock in: problem fine brush
JQ style, element operation, effect, filtering method and transformation, event object
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
随机推荐
Market status and development prospects of the global automatic tea picker industry in 2022
First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
[research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
Blog building tool recommendation (text book delivery)
1086 tree traversals again (25 points)
[SQL injection] joint query (the simplest injection method)
[backtrader source code analysis 5] rewrite several time number conversion functions in utils with Python
cookie session jwt
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
Kept hot standby and haproxy
Literature reading_ Research on the usefulness identification of tourism online comments based on semantic fusion of multimodal data (Chinese Literature)
Problems encountered in fuzzy query of SQL statements
Use Sqlalchemy module to obtain the table name and field name of the existing table in the database
On typescript and grammar
Huawei personally ended up developing 5g RF chips, breaking the monopoly of Japan and the United States
RT thread flow notes I startup, schedule, thread
第十九届浙江省 I. Barbecue
Career planning of counter attacking College Students
Shallow and first code
[set theory] relationship properties (common relationship properties | relationship properties examples | relationship operation properties)