forked from MUSA611-CPLN692-spring2019/cpln692-week3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart4-project-euler.html
59 lines (41 loc) · 1.23 KB
/
part4-project-euler.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
/* =====================
# Lab 1, Part 4 — Stretch Goal: Project Euler
## Introduction
Practice your Javascript and math skills by solving a problem on Project
Euler. Project Euler is a series of challenging math and computer science
problems that can be solved using any language (for our class, use
Javascript).
Solve the first problem on this page https://projecteuler.net/archives
(Multiples of 3 and 5). To check your answer, create an account and you will
be able to submit your final result.
If you complete problem 1, move on to problem 2!
===================== */
/* =====================
Start code
===================== */
let sum = 0;
for(let i = 1; i < 1000; i++) {
if(i%3===0 | i%5===0) {sum = sum + i;};
}
console.log('Sum = ' + sum)
let sum2 = 0;
let j = [1, 1];
for(let i=1; i < 4000000; i = j[0] + j[1]) {
if(i%2===0) {sum2 = sum2 + i};
j[0] = j[1];
j[1] = i;
//console.log("i " + i + ' j ' +j);
}
console.log('Sum2 = ' + sum2)
/* =====================
End code
===================== */
</script>
</body>
</html>