Back to Practice
#0043

Use HCF and LCM Product Relationship

EasyAptitude10 min10 XP

Problem

Two numbers have HCF 6 and LCM 180. If one number is 30, what is the other number?

Why This Matters

HCF/LCM questions become fast when you remember that for two positive integers: a * b = HCF * LCM.

Examples

Example 1
InputHCF = 6, LCM = 180, one number = 30
Output36

a*b = HCF*LCM, so 30*x = 6*180 = 1080. Therefore x = 36.

Constraints

  • Use the product relation only for two positive integers.
  • Check that the final number is divisible by the HCF.
CodeReasoning
Two numbers have HCF 6 and LCM 180. If one number is 30, what is the other number?
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Missing second number
InputHCF 6, LCM 180, one number 30
Expected36

The product of the two numbers must equal 1080.

Hidden Test Categories
One number equals the HCFOne number equals the LCMNumbers where the answer is not an integer are invalid inputs