x*y = a + b*lcm(x,y) + c*gcd(x,y)
I have to solve this eqaution.How to make a solution for it.
here a,b,c<=10^6

Any suggestions

This is hardly a C++ question, it is maths. Anyway, obviously you have made the transform (x,y>0)
[tex]lcm(x,y)=\frac{x y}{gcd(x,y)}[/tex]

That allows you to create a quadratic equation in gcd(x,y), that gives you what you the condition on gcd. That immediately excludes solutions for a large set of a,b,c. [fractional and imaginary solutions are disallowed]. For those that do have solution, then you have one of two conditions to forefill, and that gives you only one iteration variable as x conditions y.

Note, that for a,b,c < 1e6 brute force is an appropriate tool as well (well just, it order 1e12 calculations and that is a bit difficult).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.