forked from TheAlgorithms/JavaScript
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem010.js
More file actions
Latest commit
24 lines (21 loc) · 489 Bytes
/
Copy pathProblem010.js
File metadata and controls
24 lines (21 loc) · 489 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// https://projecteuler.net/problem=10
constisPrime=(number)=>{
if(number===2)returntrue
if(number%2===0)returnfalse
for(letj=3;j*j<=number;j+=2){
if(number%j===0){
returnfalse
}
}
returntrue
}
constcalculateSumOfPrimeNumbers=(maxNumber)=>{
letsum=0
for(leti=maxNumber-1;i>=2;i--){
if(isPrime(parseInt(i))===true){
sum+=i
}
}
returnsum
}
export{calculateSumOfPrimeNumbers}