Write a function named show_twos
that shows the factors of 2 in a given integer. For example, the following calls:
show_twos(0);
show_twos(5);
show_twos(18);
show_twos(68);
show_twos(-68);
show_twos(120);
should produce this output:
0 = 0
5 = 5
18 = 2 * 9
68 = 2 * 2 * 17
-68 = 2 * 2 * -17
120 = 2 * 2 * 2 * 15
The idea is to express the number as a product of factors of 2 and an odd number.
The number 120 has 3 factors of 2 multiplied by the odd number 15.
For odd numbers (e.g. 7), there are no factors of 2, so you just show the number itself.
If passed a negative integer, the only negative multiple in the result should be the
last multiplied value, as shown in the above example for show_twos(-68)
.
You may assume that the value passed is an Integer
type.