Question: CMiC | Mercer Mettl | Online Assessments (OA) | Generated Numbers (Unique Marbles)
0
Entering edit mode

Question 1: Generated Numbers (Unique Marbles)

Problem Statement:

You have a jar which initially contains N marbles. You can perform the following operations in any order:

  1. Taking out A marbles from the jar.
  2. Taking out B marbles from the jar.

Where A & B are integer values.

Your task is to find and return an integer value representing the total number of unique positive numbers of marbles that can be left behind by performing these operations, including the initial number of marbles.

Note:

  • The above operations can be performed any number of times and in any order, provided the jar never becomes empty (marbles left must be > 0).
  • The initial value of N is always included in the final count of unique marbles.

Input Specification:

  • input1: An integer value N, representing the initial number of marbles.
  • input2: An integer value A.
  • input3: An integer value B.

Output Specification:

  • Return an integer value representing the total number of unique positive numbers of marbles.

Example 1:

Input:

input1: 4

input2: 1

input3: 2

Output:

4

Explanation:

You can take out A=1 or B=2 marbles.

The unique values you can reach are 4 (initial), 3 (taking 1), 2 (taking 2), and 1 (taking 2 then 1, or 1 three times). Output is 4.

 

Example 2:

Input:

input1: 10

input2: 2

input3: 5

Output:

8

Explanation:

From 10, we can reach the following positive configurations by successively subtracting 2 or 5: 10, 8, 6, 4, 2, 5, 3, and 1. Output is 8.

Login before adding your answer.

Similar Posts
Loading Similar Posts