-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheuler10.html
38 lines (37 loc) · 831 Bytes
/
euler10.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<html>
<head>
<script type="text/javascript">
function sum_primes()
{
var limit=2000000;
var sum=0;
var i;
for(i=2;i<limit;i++)
{
if(isPrime(i))
{
sum+=i;
}
}
alert("Sum of primes below 2 million is "+sum);
}
function isPrime(num)
{
sqrt=Math.pow(num,0.5);
sqrt=Math.floor(sqrt);
iP=2;
while(iP<=sqrt)
{
if(num%iP==0)
{
return false;
}
iP++;
}
return true;
}
</script>
</head>
<body onload="sum_primes();">
</body>
</html>