logo CodeStepByStep logo

show_twos

Language/Type: Python loops %

Write a function named show_twos that shows the factors of 2 in a given integer. For example, consider the following calls:

show_twos(7)
show_twos(18)
show_twos(68)
show_twos(120)

These calls should produce this output:

7 = 7
18 = 2 * 9
68 = 2 * 2 * 17
120 = 2 * 2 * 2 * 15
Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.