Nth Multiple
Basic Accuracy: 26.85% Submissions: 699 Points: 1

You are given a series 1, 1, 2, 3, 5, 8,.... . Your task is to tell the position of Nth multiple of a number - A. Both A and Nth multiple are part of the given series. 

Example : 
Input : 

The first line of input contains an integer T denoting the Test cases. Then T test cases follow. 
Second line contains Skill value of N
Third line contains Skill value of A

Output : 
Position of Nth multiple of A in the given series(indexing starting from 1)

Constraints :
1 ≤ T ≤ 50
1 ≤ N ≤ 10^8
1 ≤ A ≤ 10^8


Input : 
2
5
4
2
3

Output : 
30
8

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Nth Multiple

Output Window