Magicsheet logo

Smallest Greater Multiple Made of Two Digits

Medium
73.4%
Updated 6/1/2025

Asked by 1 Company

Smallest Greater Multiple Made of Two Digits

What is this problem about?

The "Smallest Greater Multiple Made of Two Digits" interview question asks you to find the smallest integer greater than a given k that is a multiple of digit1 and digit2. This "Smallest Greater Multiple Made of Two Digits coding problem" is essentially asking for the smallest multiple of the Least Common Multiple (LCM) of the two digits that is strictly greater than k.

Why is this asked in interviews?

PayPal and other fintech companies use this to check for basic algorithmic efficiency and mathematical understanding. It tests if you know how to calculate LCM and how to use it to jump directly to the answer instead of iterating one by one. It's a "MEDIUM" problem because it requires a bit more than just basic math—it requires an optimized approach.

Algorithmic pattern used

This uses the "Math and LCM interview pattern".

  1. Calculate the LCM of digit1 and digit2. LCM(a, b) = (a * b) / GCD(a, b).
  2. Find the smallest multiple of this LCM that is greater than k.
  3. This can be done with a simple formula: ((k / LCM) + 1) * LCM.

Example explanation

Let k = 20, digit1 = 3, digit2 = 4.

  1. LCM(3, 4) = 12.
  2. Multiples of 12 are 12, 24, 36...
  3. Smallest multiple greater than 20 is 24. Formula check: (20 / 12) + 1 = 1 + 1 = 2. 2 * 12 = 24. Result: 24.

Common mistakes candidates make

The most frequent mistake is iterating from k+1 and checking each number for divisibility. While this works, it is inefficient if the LCM is very large. Another mistake is forgetting that the digits themselves might be 0 (though usually not the case in this problem) or not handling the GCD correctly when calculating LCM.

Interview preparation tip

Always remember the relationship between GCD and LCM. a * b = GCD(a, b) * LCM(a, b). This formula is a building block for many "Smallest Greater Multiple Made of Two Digits interview question" variations.

Similar Questions