P17041 [GeeksforGeeks] Lcm triplet1501
普及
题目描述

Given a number N.Find the maximum possible LCM that can be attained by any three numbers less than or equal to N.
Note- LCM stands for Lowest Common Multiple. Also, Numbers can be repeated.
Example 1:
Input:
N=9
Output:
504
Explanation:
504 is the maximum LCM that can be attained
by any triplet of numbers less than or equal 9.
The triplet which has this LCM is {7,8,9}.
Example 2:
Input:
N=7
Output:
210
Explanation:
210 is the maximum LCM that can be attained
by any triplet of numbers less than or equal 7.
The triplet which has this LCM is {5,6,7}.
Your Task:
You don't need to read input or print anything. Your task is to complete the function lcmTriplets() that takes a number N as input parameter and returns the maximum LCM that can be attained by any three numbers less than or equal to N.
Expected Time Complexity:O(logN)
Expected Auxillary Space:O(logN)
Constraints:
1<=N<=10^{6}

输入格式

见题面

输出格式

见题面

样例输入
N=9
样例输出
504