Project Euler: Problem 5

By | 17. April 2013

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?

int times = 0;
for (int i=1; i<1000000000; i++) {
	for (int j=1; j<=20; j++) {
		if (i%j==0) {
			times++;
		}
	}
	if (times==20) {
		System.out.println(i);
		break;
	}
	times = 0;
}

Lösung: 232792560

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.