-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem2.java
More file actions
37 lines (33 loc) · 723 Bytes
/
Copy pathProblem2.java
File metadata and controls
37 lines (33 loc) · 723 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
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Problem 2 from project Euler.
*
* @author Devin Hurley
* @version (a version number or a date)
*/
public class Problem2
{
/**
* Constructor for objects of class Problem2
*/
public Problem2()
{
// initialise instance variables
}
public static void main(String[] args){
long count = 0;
long i,a=1,b=1,c=0,t = 4000000;
for(i=0;i<t-2;i++) {
c=a+b;
a=b;
b=c;
if(c < 4000000){
if(c%2.0 == 0){
count = c+ count;
}
}else{
break;
}
}
System.out.println(" The sum of evens is: " + count);
}
}