# Find three integers less than or equal to N such that their LCM is maximum in C++

C++Server Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

66 Lectures 5.5 hours

In this tutorial, we will be discussing a program to find three integers less than or equal to N such that their LCM is maximum.

For this we will be provided with an integer value. Our task is to find other three integers smaller than the given value such that their LCM is maximum.

## Example

Live Demo

#include <bits/stdc++.h>
using namespace std;
//finding three integers less than given value
//having maximum LCM
void findMaximumLCM(int n) {
if (n % 2 != 0) {
cout << n << " " << (n - 1) << " " << (n - 2);
}
else if (__gcd(n, (n - 3)) == 1) {
cout << n << " " << (n - 1) << " " << (n - 3);
}
else {
cout << (n - 1) << " " << (n - 2) << " " << (n - 3);
}
}
int main() {
int number = 34;
findMaximumLCM(number);
return 0;
}

## Output

34 33 31