Good old fashion paper and pencil (actually a pen ) got the answer of <b>2519</b>.
The simplest way is to find the LCM (Least Common Multiple) of the numbers 2, 3, 4, 5, 6, 7, 8 and 9, then subtract 1 from it. The LCM of 2, 3, 4, 5, 6, 7, 8 and 9 is 2520, Therefore, the answer is 2519.
Good Luck!
-Flame
*********************
I made in java language:
public class FindTheNumber {
public static void main(String[] args) {
new FindTheNumber().findNumber();
}
void findNumber() {
int number = 10;
int div;
boolean foundTheNumber = false;
while (true) {
for (div = 2; div < 10; div++) {
if (rightNumber(number, div)) {
foundTheNumber = true;
for (int d = div; d >= 2; d–) {
if (rightNumber(number, d)) {
} else {
foundTheNumber = false;
break;
}
}
} else {
foundTheNumber = false;
break;
}
}
if (foundTheNumber && div == 10) {
System.out.println(“The Number is : ” + number );
System.exit(0);
} else {
number++;
}
}
}
boolean rightNumber(int number, int divider) {
if (number % divider == divider – 1) {
return true;
} else {
return false;
}
}
}
if you want to change it into LCM, just change “divider – 1” in rightNumber() method with “0”.
anyone have a better logic?
-Hendi
Discuss This Question: 8 Replies