-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmallestMultiple.java
More file actions
42 lines (37 loc) · 1.03 KB
/
Copy pathSmallestMultiple.java
File metadata and controls
42 lines (37 loc) · 1.03 KB
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
/** Project Euler.net
*
* PROBLEM 5:
* 2520 is the smallest number that can be divided by each of the numbers
* 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?
*
* ANSWER:
* 232792560
*
* @author
* Natalie Kerby :: ndkerby@gmail.com
*/
import math.MATH;
import java.util.*;
public class SmallestMultiple {
public static final int DIVISIBLE_NUMBER = 20;
public static void main(String[] args) {
int smallestMultiple = 0;
boolean found = false;
do{
smallestMultiple+=DIVISIBLE_NUMBER;
int count = 0;
for(int i = 1; i <= DIVISIBLE_NUMBER; i++){
if(smallestMultiple%i == 0){
count++;
}
if(count == DIVISIBLE_NUMBER){
found = true;
}
}
} while (!found);
System.out.println("Smallest Multiple:" + smallestMultiple);
}
}