6.1 Display the number of bits needed to represent a number

Block-based solution

View solution

This is just one of many possible solutions:

whenclickedaskPlease enter the number of dots:andwaitsettotal number of dotstoanswersetbitsto0setbit valueto1repeatuntiltotalnumberofdots<bitvaluesetbit valuetobitvalue*2changebitsby1sayjoinjoinjoinYou will need bits bits to store number totalnumberofdots

Back to programming challenge