Amenable number

An amenable number is a positive integer for which there exists a multiset of as many integers as the original number that both add up to the original number and when multiplied together give the original number. To put it algebraically, for a positive integer n, there is a multiset of n integers {a1, ..., an}, for which the equalities $$ n = \sum_{i=1}^n a_i = \prod_{i=1}^n a_i$$ hold. Negative numbers are allowed in the multiset. For example, 5 is amenable since 5 = 1 + (-1) + 1 + (-1) + 5. All and only those numbers congruent to 0 or 1 (mod 4), except 4, are amenable.

The first few amenable numbers are: 1, 5, 8, 9, 12, 13 ...

A solution for integers of the form n = 4k + 1 could be given by a set of 2k (+1)s and 2k (-1)s and n itself. (This generalizes the example of 5 given above.)

Although not obvious from the definition, the set of amenable numbers is closed under multiplication (the product of two amenable numbers is an amenable number).

All composite numbers would be amenable if the multiset was allowed to be of any length, because, even if other solutions are available, one can always obtain a solution by taking the prime factorization (expressed with repeated factors rather than exponents) and add as many 1s as necessary to add up to n. The product of this set of integers will yield n no matter how many 1s there are in the set. Furthermore, still under this assumption, any integer n would be amenable. Consider the inelegant solution for n of {1, -1, 1, -1, n}. In the sum, the positive ones are cancelled out by the negative ones, leaving n, while in the product, the two negative ones cancel out the effect of their signs.

Amenable numbers should not be confused with amicable numbers, which are pairs of integers whose divisors add up to each other.