2 points
7.
option can be
used to find the GCD and LCM
of two numbers.
O #NAME
O date or time
O Math & TRIG->GCD
Answers
Answered by
2
Answer:
We need to find number of possible pairs (a, b) such that GCD(a, b) is equal to given G and LCM (a, b) such that LCM(a, b) is equal to given L.
Examples:
Input : G = 2, L = 12 Output : 4 Explanation : There are 4 possible pairs : (2, 12), (4, 6), (6, 4), (12, 2) Input : G = 3, L = 6 Output : 2 Explanation : There are 2 possible pairs : (3, 6), (6, 3)
Explanation:
Solution 1 (Simple):
Solution 1 (Simple):Since a and b both will be less than or equal to lcm(a, b) L, so we try all possible pairs that have product equal to L * G. Note that product of a and b is same as product of gcd(a, b) and lcm(a, b), a*b = G*L.
Similar questions