## Interview Question

Country: India

Comment hidden because of low score. Click to expand.
1
of 1 vote

given: xy = a + b*lcm + c*gcd
elementry maths: xy = lcm*gcd, on substitution, we get: lcm*gcd = a + b*lcm + c*gcd

on rearranging, we get (gcd - b)(lcm - c) = a + bc.
This is a program of finding all pairs of numbers p,q such that pq = k.
=> lcm - c = x1, gcd - b = x2
=> lcm = x1 + c, gcd = x2 + b

Now xy = lcm*gcd => x*y = (x1+c)(x2+b) Which is again a case of pq = k. Call the same function again and count the number of values found, which is our output.

Comment hidden because of low score. Click to expand.
0

``````ArrayList<Pair> findProd(int k) {
ArrayList<Pair> list = new ArrayList<Pair>();
for (int i = 1; i <= (Integer)Math.sqrt(k); i++) {
if (k % i == 0) {
}
}

return list;
}``````

Comment hidden because of low score. Click to expand.
0

Thanks Ashu.............

Comment hidden because of low score. Click to expand.

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.