I did the conversion with recursion 😃😁.. But i have this doubt 👇 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I did the conversion with recursion 😃😁.. But i have this doubt 👇

https://code.sololearn.com/c9TA1q1i0LeT/?ref=app I did the conversion with recursion 😃😁.. But i have this doubt 👇 In case if decimal is 8 , the binary will be 0+(0*10)+(0*10)+(1*10) is 1000 instead of 10, why is that? Also tell me how can i furthur optimize this program

26th Apr 2019, 9:13 AM
An IL
An IL - avatar
3 Answers
+ 16
Continuing the msg of Kira... And read the Soln from LSB(least significant bit)
26th Apr 2019, 10:11 AM
Nimit Sandeep Jhunjhunwala
Nimit Sandeep Jhunjhunwala - avatar
+ 1
Thats not how you do decimal to binary conversion. You have to divide the number with the base 2(for binary) and note down the remainder in every step. Binary of 8 is 1000 not 10
26th Apr 2019, 9:37 AM
kiRA
kiRA - avatar
0
Hey kiRA But the code is working. input 8 gives output 1000. I just can't understand the calculation done there.
26th Apr 2019, 11:41 AM
An IL
An IL - avatar