package margusmartseppcode.From_1_to_9;
public class Problem_5 {
static long gcd(long a, long b) {
if (b == 0)
return Math.abs(a);
return gcd(b, a % b);
}
static long lcm(long a, long b) {
return (a * b) / gcd(a, b);
}
public static void main(String[] args) {
long result = 1;
for (long i = 2; i < 21; i++)
result = lcm(result, i);
System.out.println(result);
}
}
No comments:
Post a Comment