Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.
Wrong:
=====
At START: R = 00110010 D = 00010111 Q = 00000000
After 1: R = 00011011 D = 00010111 Q = 00000000
After 2a: R = 00011011 D = 00010111 Q = 00000001
After 3: R = 00011011 D = 00001011 Q = 00000001
After 1: R = 00010000 D = 00001011 Q = 00000001
After 2a: R = 00010000 D = 00001011 Q = 00000011
After 3: R = 00010000 D = 00000101 Q = 00000011
After 1: R = 00001011 D = 00000101 Q = 00000011
After 2a: R = 00001011 D = 00000101 Q = 00000111
After 3: R = 00001011 D = 00000010 Q = 00000111
After 1: R = 00001001 D = 00000010 Q = 00000111
After 2a: R = 00001001 D = 00000010 Q = 00001111
After 3: R = 00001001 D = 00000001 Q = 00001111
After 1: R = 00001000 D = 00000001 Q = 00001111
After 2a: R = 00001000 D = 00000001 Q = 00011111
After 3: R = 00001000 D = 00000000 Q = 00011111
After 1: R = 00001000 D = 00000000 Q = 00011111
After 2a: R = 00001000 D = 00000000 Q = 00111111
After 3: R = 00001000 D = 00000000 Q = 00111111
After 1: R = 00001000 D = 00000000 Q = 00111111
After 2a: R = 00001000 D = 00000000 Q = 01111111
After 3: R = 00001000 D = 00000000 Q = 01111111
After 1: R = 00001000 D = 00000000 Q = 01111111
After 2a: R = 00001000 D = 00000000 Q = 11111111
After 3: R = 00001000 D = 00000000 Q = 11111111
Hence the result of the program is:
"50 / 23 is -1 remainder 8" -- not very promising
RIGHT:
=====
At START: R = 000000 110010 D = 010111 000000 Q = 000000 000000
first round:
After 1: R < 0
After 2b: R = 110010 D = 010111 000000 Q = 000000
After 3: R = 110010 D = 001011 100000 Q = 000000
second round:
After 1: R < 0
...
After 3: R = 110010 D = 000000 101110 Q = 000000
sixth round:
After 1: R = 000100 D = 000000 101110 Q = 000000
After 2a: R = 000100 D = 101110 Q = 000001
After 3: R = 000100 D = 010111 Q = 000001
seventh round:
After 1: R < 0
After 2b: R = 000100 D = 010111 Q = 000010
After 3: R = 000100 D = 001011 Q = 000010
END
Now the result is "50 / 23 is 2 remainder 4" as expected