The solution uses three steps to transform the binary number:

  1. Decrement the binary number by one.
  2. Increment the unary number by one.
  3. If the binary number is bigger then zero return to step 1.

Decrementing a binary number by one

  1. Search the rightmost one.
  2. Replace it with a zero.
  3. Replace all zero to the right with ones.

Incrementing a unary number by one
The unary number can be incremented by one by simply prepending an additional one in front.