![]() |
VOOZH | about |
Given n fractions as two arrays Num and Den. The task is to find out the L.C.M of the fractions.
Examples:
Input: num[] = {1, 7, 4}, den[] = {2, 3, 6}
Output: LCM is = 28/1
The given fractions are 1/2, 7/3 and 4/6.
The LCM is 28/1Input: num[] = {24, 48, 72, 96}, den[] = {2, 6, 8, 3}
Output: LCM is = 288/1
LCM of A/B and C/D = (LCM of A and C) / (HCF of B and D)
Below is the implementation of above approach:
LCM is = 28/1
Time Complexity: O(N * log(min(a, b)))
Auxiliary Space: O(log(min(a, b)))
Given n fractions as two arrays Num and Den. The task is to find out the L.C.M of the fractions.
Input: num[] = {1, 7, 4}, den[] = {2, 3, 6}
Output: HCF is 1/6
The given fractions are 1/2, 7/3 and 4/6.
The HCF is 1/6Input: num[] = {24, 48, 72, 96}, den[] = {2, 6, 8, 3}
Output: HCF is 1/1
HCF of A/B and C/D = (HCF of A and C) / (LCM of B and D)
Below is the implementation of above approach:
HCF is = 1/1