Write an algorithm, called Decomposition_Powers_Three, which produces the decomposition of each integer using powers of 3, namely 1, 3, 9, 27, and 81, and the + and – operators. Each power of 3 should appear at most once in the decomposition.
This kind of looks like a homework problem so I won't give you the code but I will point you in the correct direction as this is a great problem for intuitive thinking.
You can solve this problem with the following operator: %
This is the modulus operator. If you don't know already, it returns the remainder of a division problem. For example:
30 % 4 = 2 (4*7 = 28 remainder = 2).
With this information, you should be able to solve this algorithm. Good luck!