Nth Number - I

2

3 votes
, mathamatics, greatest common divisor, Basic Math, easy, mathematics, Mathematics, basic math, Math
Problem

You are given two numbers a and b.
You have to find the Nth number which is divisible by a and b.

Example

Consider a = 3, b= 2, N = 3. You must find the Nth number which is divisible by a and b.

Here the answer is 18

Function description:

Complete the solve function provided in the editor. This function takes the following 3 parameters and returns the Nth number which is divisible by a and b.

  • a: Represents an integer denoting a
  • b: Represents an integer denoting b
  • N: Represents an integer denoting the Nth number that is to be found.

Input format

Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).

  • First line: T, the number of test cases
  • Second line: a, b and N .

Output format

For each test case, print the Nth number in a new line.

Constraints :

1t105

1a,b104

1N109

Code snippets (also called starter code/boilerplate code)

This question has code snippets for C, CPP, Java, and Python.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The numbers which are divisible by both 4 and 6 are 12,24,36,48..... and here the 3rd number is 36.

Editor Image

?