Least common multiple of the largest training algorithm
Resource constraints
Time limit: 1.0s Memory Limit: 256.0MB
Problem Description
Given a positive integer N, Q ~ from any 1 N elect three numbers, their least common multiple can be up to much.
Input Format
Enter a positive integer N.
Output Format
Output An integer that represents you find the least common multiple.
Sample input
9
Sample Output
504
Data size and convention
1 <= N <= 106。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long n = in.nextLong();
in.close();
if (n <= 2) {
System.out.print(n);
return;
}
if (0 == n % 2) {
if (0 != n % 3) {
System.out.print((n * (n - 1) * (n - 3)));
} else {
System.out.print((n - 1) * (n - 2) * (n - 3));
}
} else {
System.out.print(n * (n - 1) * (n - 2));
}
}
}