C++ code to get two numbers in range x with given rules

Suppose we have a number x. We have to find two integers a and b, such that both of them will be in between 1 and x, a is divisible by b, a * b > x but a/b

To solve this, we will follow these steps −

if x 

Example

Let us see the following implementation to get better understanding −

#include 
using namespace std;
void solve(int x){
   if (x 

Input

10

Output

10,10
Updated on: 2022-03-15T06:32:01+05:30

296 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements