Skip to content

Commit 7aba8ad

Browse files
authored
add challenge
1 parent 1df235d commit 7aba8ad

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function isPrime(number) {
2+
var start = 2;
3+
while (start <= Math.sqrt(number)) {
4+
if(number % start++ < 1) return false;
5+
}
6+
return true;
7+
}
8+
9+
function sumPrimes(num) {
10+
var sum = 0;
11+
for(var i = 2; i <= num; i++) {
12+
if(isPrime(i)) {
13+
sum += i;
14+
}
15+
}
16+
return sum;
17+
}
18+
19+
// test
20+
sumPrimes(10);

0 commit comments

Comments
 (0)