0

Okay, so I'm fully well aware of how this is applied in C# and C. But I can't figure it out in Swift 3.

Is there an algorithm to convert n into negabinary base (-2).

 7 = -3*-2 + 1  (least significant digit)
-3 =  2*-2 + 1
 2 = -1*-2 + 0
-1 =  1*-2 + 1
 1 =  0*-2 + 1  (most significant digit)
  • 1
    Hi! the following link might be helpful to you. https://stackoverflow.com/questions/37637781/calculating-the-negabinary-representation-of-a-given-number-without-loops – Madhur Jan 23 '18 at 04:19
  • 1
    Where did you get stuck? – Henry Jan 23 '18 at 04:39

0 Answers0