Question: Write a recursive method that parses a positive binary number as a string into a decimal integer. //Assume the input is always digit only. //If

Write a recursive method that parses a positive binary number as a string into a decimal integer.

//Assume the input is always digit only.

//If the input is not a binary number, return the same number in the integer format

 

Sample Input1 //A binary input

11

 

Sample Output1

3

 

Sample Input2 //Not a binary input

00112

 

Sample Output2

112

Step by Step Solution

3.52 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

def binarytodecimalbinarystr Base case if the input is not a binary number return the intege... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!