Data Structure & Algorithms
DSA
Bit Manipulations
Decimal to Any Base

Decimal to Any Base

Problem Description

Given a decimal number A and a base B, convert it into its equivalent number in base B.

Problem Constraints

0 <= A <= 512
2 <= B <= 10

Input Format

The first argument will be decimal number A.
The second argument will be base B.

Output Format

Return the conversion of A in base B.

Example Input

Input 1:
A = 4
B = 3

Input 2:
A = 4
B = 2 

Example Output

Output 1:
11

Output 2:
100

Example Explanation

Explanation 1:
The decimal 10 in base 2 is 1010.

Explanation 2:
The decimal 8 in base 3 is 22.

Output

Java
 
Python
 
JavaScript