Just for fun… Here’s the pseudocode for the method of building a binary number from a decimal number, based on the Russian peasant method of multiplication:

function mybin(mydec) {

mybin = “”;

do while mydec > 0 {

if mydec is odd: {

mydec = mydec – 1;

mybin = “1” + mybin; }

else: mybin = “0” + mybin;

mydec = mydec / 2; }

return mybin; }