...
/Solution Review: Convert Decimal Number to Binary Number
Solution Review: Convert Decimal Number to Binary Number
This review provides a detailed analysis of the solution to convert a decimal number to binary number.
We'll cover the following...
Solution: Using Recursion
Press + to interact
def decimalToBinary(testVariable) :# Base Caseif testVariable <= 1:return str(testVariable)# Recursive Caseelse:return decimalToBinary(testVariable // 2) + decimalToBinary(testVariable % 2) # Floor division -# division that results into whole number adjusted to the left in the number line# Driver CodetestVariable = 11print(decimalToBinary(testVariable))
Explanation:
To convert a decimal number to a binary number, keep track of the and the remaining ...