Increment
Submissions: 351   Accuracy:

45.32%

  Difficulty: Easy   Marks: 2

Given a base and a number in that base, increment the number by one and print the resulting number in that base only.

Input: First line contains an integer T, denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line contains an integer B, denoting the base. Second line contains a four-digit number N.

Note: {A,B,C,D,E,F} has been used for numbers greater than 9 in any base.

Output: Print the incremented value of the number.

Note: You have to ignore the preceding zeroes in input that are used to make it four-digit. Please see example for more details.

Constraints:
1 <= T <= 70
2 <= B <= 16
0000 <= N <= Max value in that base (e.g. 1111 for base 2, FFFF for base 16, etc.)

Example:

Input:
3
2
0010
13
2139
16
FFFF

Output:
11
213A
10000

** For More Input/Output Examples Use 'Expected Output' option **

Author: atharv


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.