Input: any number in 1-15 or 64-79 range which is a sum of either (1, 2, 4, 8, 64) in any combination
Output: an array of integers from this list: (1, 2, 4, 8, 64) the sum of which equals the input number.
e.g.
- input 72, output array(8, 64)
- input 13, output array(1, 4, 8)
mkasberg provided the solution:
Since you have not included your code in the question, no one can help you with your code. But here is a general approach without any code that should work for this problem.
Start with your input number and an empty array to hold the sum elements. Iterate over your array of addends in descending order, appending each one to your sum array and subtracting it from the input number until the input number reaches zero.