public class Euler5 {
    static long gcd(long a, long b) {
        while (b != 0) {
            long t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }

    static long solve(int n) {
        long value = 1;
        for (int k = 2; k <= n; k++) {
            value = lcm(value, k);
        }
        return value;
    }

    public static void main(String[] args) {
        assert solve(10) == 2520 : "Checkpoint failed for n=10";
        System.out.println(solve(20));
    }
}
