-
Make variables called:
decimal_numberand set its value to the input number given by the end user.bit_valueand set its value to 1. Find the smallest bit value which is larger thandecimal_numberby doubling value ofbit_valueuntil it is bigger than thedecimal_number(by using a while loop whilebit_valueis less than or equal todecimal_number).
-
Set the variable
bit_valueto 1 and find the smallestbit_valuewhich is larger thandecimal_numberby multiplyingbit_valueby 2 until it is larger thandecimal number. You can do this by using a while loop. -
Now divide the
bit_valueby 2 and check ifdecimal_numberis greater than or equal tobit_value. If it is, print "high" for a high note and subtractbit_valuefromdecimal_number. If not, print "low" for a low note. Repeat untilbit_valueis equal to 1 (by using a while loop whilebit_valueis greater than 1)