Ad
  • Custom User Avatar

    If sum=12 in add_binary method, then place_holder in the while loop first takes the value of 3 and then it takes the value of 2. Hence number = 0 + 10^3 + 10^2 = 1100 and sum = 12 - 2^3 - 2^2 = 0 thus exiting the loop. Run over your logic again.

  • Custom User Avatar

    It's just a different way of solving the problem. I believe that a good balance between being aware of the correct syntax and being able to re-derive basic functions is essential for any good coder.