-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblemFive
30 lines (28 loc) · 1.01 KB
/
ProblemFive
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
/**
* Gabriel Menescal
*
* Problem 5:
*
* 2520 is the smallest number that can be divided by each of the number from 1 to 10
* without any remainder. What is the smallest positive number that is evenly divisible
* by all of the numbers from 1 to 20?
*/
public class ProblemFive {
public static void main(String[] args) {
boolean found = false;
int i = 2520;
long startTime = System.currentTimeMillis();
while (!found) {
i++;
if (i % 2 == 0 && i % 3 == 0 && i % 4 == 0 && i % 5 == 0 && i % 6 == 0 && i % 7 == 0 && i % 8 == 0 && i % 9 == 0
&& i % 10 == 0 && i % 11 == 0 && i % 12 == 0 && i % 13 == 0 && i % 14 == 0 && i % 15 == 0 && i % 16 == 0
&& i % 17 == 0 && i % 18 == 0 && i % 19 == 0 && i % 20 == 0) {
found = true;
}
}
System.out.println("run time = " + (System.currentTimeMillis() - startTime));
System.out.println(i);
}
}
// run time: 616ms
// OUTPUT: 232792560