...

/

Challenge 3: Convert Decimal Number to Binary Number

Challenge 3: Convert Decimal Number to Binary Number

In this lesson, you will write the code to convert a decimal number into an equivalent binary number using recursion.

How does the Decimal to Binary Conversion work?

Given a decimal number, you keep dividing the number by 2 until it reaches 1 and records the remainder at each step.

The resulting list of remainders is the equivalent binary number for your decimal number.

For example:

Input : 1919

Output : 1001110011

The illustration below explains the process of converting a decimal number to a binary number.

Access this course and 1400+ top-rated courses and projects.