Given a number N(>=3). The task is to find the three integers (<=N) such that LCM of these three integers is maximum.
Input: N = 3 Output: 1 2 3 Input: N = 5 Output: 3 4 5
Approach: Since the task is to maximize the LCM, so if all three numbers don’t have any common factor then the LCM will be the product of those three numbers and that will be maximum.
- If n is odd then the answer will be n, n-1, n-2.
- If n is even,
- If gcd of n and n-3 is 1 then answer will be n, n-1, n-3.
- Otherwise, n-1, n-2, n-3 will be required answer.
Below is the implementation of the above approach:
11 10 9
- Find any K distinct odd integers such that their sum is equal to N
- Find the first N integers such that the sum of their digits is equal to 10
- Find a pair with maximum product in array of Integers
- Find integers that divides maximum number of elements of the array
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Find four factors of N with maximum product and sum equal to N
- Find four factors of N with maximum product and sum equal to N | Set 3
- Find four factors of N with maximum product and sum equal to N | Set-2
- Find two equal subsequences of maximum length with at least one different index
- Find maximum product of digits among numbers less than or equal to N
- Find maximum subset sum formed by partitioning any subset of array into 2 partitions with equal sum
- Count number of integers less than or equal to N which has exactly 9 divisors
- Check if the sum of distinct digits of two integers are equal
- Remove two consecutive integers from 1 to N to make sum equal to S
- Check if N rectangles of equal area can be formed from (4 * N) integers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.