Can I use a loop to print the binary numbers 2 through 5?


#1

Question

Can I use a loop to print the binary numbers 2 through 5?

Answer

Yes! It’ll save you the agony of writing the same line of code 4 times, if nothing else. To print each number in a loop, just be sure you’re not adding any additional text or unnecessary line breaks. The instructions want each number on a new line by itself.
For example, in pseudo code what we’d do is:

for numbers 2 through 5:
  print binary of current number