Back to course home
0% completed
Vote For New Content
4. Converting Decimal to Binary
Problem Statement
Write a Recursive Procedure to Convert a Decimal Number to a Binary Equivalent.
Given a decimal number, we need to convert it to its binary representation, as explained in the following table:
Input(s) | Output(s) | Explanation |
---|---|---|
Decimal Number = 10 | Binary Number = 1010 | The decimal number 10 can be represented as 1010 in binary. Each digit in the binary representation corresponds to the powers of 2. |
Decimal Number = 27 | Binary Number = 11011 | The decimal number 27 can be represented as 11011 in binary. Each digit in the binary representation corresponds to the powers of 2. |
Decimal Number = 5 | Binary Number = 101 | The decimal number 5 can be represented as 101 in binary. Each digit in the binary representation corresponds to the powers of 2. |
Constraints:
- 0 <= n <= 10<sup>9</sup>
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page
Problem Statement
Try it yourself