Project Euler #5 code example
Example: Project Euler #5
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int a0 = 0; a0 < t; a0++){
int n = in.nextInt();
int a = 1;
int r = 0;
for (int b = 1; b <= n; b++) {
r = a * b;
for (int i = b; i > 1; i--) {
if (a % i == 0 && b % i == 0) {
r = r / i;
break;
}
}
a = r;
}
System.out.println(r);
}
}