Nov-02-2020, 12:18 AM
With a generalized solution, since you don't know if one of the numbers is 1, you need to find all of the permutations of the numbers, allowing repeats, of n numbers. Once you have the permutations, see how many add up to n.
Potential is a lot of permutations. If you have 3 numbers as in your example, and n=4 as in the example, you will have 3 1 digit options, 3 squared 2 digit options, 3 cubed 3 digit options, and 3 to the 4th power 4 digit options. Total is 3+9+27+81=120 combinations. Most will not add up to 4.
Potential is a lot of permutations. If you have 3 numbers as in your example, and n=4 as in the example, you will have 3 1 digit options, 3 squared 2 digit options, 3 cubed 3 digit options, and 3 to the 4th power 4 digit options. Total is 3+9+27+81=120 combinations. Most will not add up to 4.