# Give the general formula for the integer $n$

For the following equation:- $$a_1+a_2+a_3.....+a_n=a_1a_2a_3.....a_n = n$$
For $a_1,a_2...a_n \in \mathbb Z$, find the general form of the integer n.

Note that we need $n$ summands/factors

Note:- Regarding the explanation of the term "general form":
For instance, even numbers are of the general form $2m.$ and rational numbers are of the general form $p/q,etc$. I mean it in that way.

PS: My guess is that we have to use some general formula for multivariable diophantine equation but I don't even know what to do if it is a multivariable diophantine equation.

• why the downvote? Dec 19, 2016 at 13:59
• Are there any examples other than $n=1=a_1$? (also not the downvote).
– lulu
Dec 19, 2016 at 14:04
• Are you sure it is integers you want? So something like $1 + (-1) + 1 + (-1) + 5 = 1 \cdot (-1) \cdot 1 \cdot (-1) \cdot 5 = 5$ would be ok? Dec 19, 2016 at 14:05
• @Peter Oh, by all means exclude $0$. I'd have said it was more interesting if subscript $n$ was not the same as value $n$. That way we could have things like $1+2+3=1\times 2\times 3$.
– lulu
Dec 19, 2016 at 14:07
• $1,-1,1,-1,1,1,1,3,3$ also works... high values of $a_i$ are factorization of $n$, and if something remains it is spread across the ones...
– Sil
Dec 19, 2016 at 14:25

Systematically considering numbers $n$ from $1$ to $20$ gives the following solutions (written giving product forms only):

\begin{align} 1&=1^1\\ 5&=5^1\cdot1^2\cdot(-1)^2\\ 8&=4^1\cdot2^1\cdot1^4\cdot(-1)^2\\ 9&=9^1\cdot1^4\cdot(-1)^4\\ &=3^2\cdot1^5\cdot(-1)^2\\ 12&=3^1\cdot2^2\cdot1^7\cdot(-1)^2\\ 13&=13^1\cdot1^6\cdot(-1)^6\\ 16&=8^1\cdot2^1\cdot1^{10}\cdot(-1)^4\\ &=2^4\cdot1^6\cdot(-1)^6\\ 17&=17^1\cdot1^8\cdot(-1)^8\\ 20&=5^1\cdot2^2\cdot1^{15}\cdot(-1)^4\quad\text{(but see the Remark at bottom)} \end{align}

Checking the sequence $1,5,8,9,12,13,16,17,20$ at OEIS leads to the sequence of amenable numbers, which gives a link to a solution by O.P. Lossers in the Math Monthly, April, 1998 (vol. 105, no. 4), pg. 368. Lossers showed that a positive integer $n$ is "amenable" if and only if $n\equiv0,1$ mod $4$ and $n\not=4$.

Here is the gist of Losser's solution (which makes me realize my "systematic" approach overlooked the possibility of negative numbers other than $-1$):

\begin{align} 4k+1&=(4k+1)^1\cdot1^{2k}\cdot(-1)^{2k}\\ 8k&=(4k)^1\cdot2^1\cdot1^{6k-2}\cdot(-1)^{2k}\\ 8k+4&=(4k+2)^1\cdot1^{6k+3}\cdot(-1)^{2k-1}\cdot(-2)^1\quad\text{if }k\ge1 \end{align}

If $n=4k+2$, then just one factor can be even, so that the other $4k+1$ factors are odd, in which case the sum of the factors is odd, so cannot equal $n$.

If $n=4k-1$, all the factors are odd and an odd number must be congruent to $-1$ mod $4$, leaving the rest congruent to $1$ mod $4$, which leads to a sum congruent to $1$ mod $4$. That is, if $2m-1$ factors are congruent to $-1$ mod $4$, then $n-(2m-1)=4k-2m$ factors are congruent to $1$ mod $4$, so that their sum is congruent to $(4k-2m)(1)+(2m-1)(-1)=4k+1\equiv1$ mod $4$.

Finally, the case $n=4$ (i.e., $8k+4$ with $k=0$, which falls outside the scope of the formula $8k+4=(4k+2)^1\cdot1^{6k+3}\cdot(-1)^{2k-1}\cdot(-2)^1$ because the exponents must all be non-negative) is dispatched by hand.

Remark (added later): In retrospect, I realize I very nearly missed finding the OEIS entry for the amenable numbers, and thus Losser's solution. My "systematic" approach missed the correct factorization $20=10^1\cdot1^{15}\cdot(-1)^3\cdot(-2)^1$, but fortunately found an incorrect one, $5^1\cdot2^2\cdot1^{15}\cdot(-1)^4$, which is incorrect because it has $1+2+15+4=22$ factors, not $20$. Entering just $1,5,8,9,12,13,16,17$ at OEIS, of course, still produces the amenable numbers, but if I'd entered $1,5,8,9,12,13,16,17,21$, instead, I'd have gotten nothing. (On the other hand, I might have still found it and realized I'd overlooked the correct factorization for $n=20$, because when an OEIS search produces nothing, I usually try again with just the first portion of the sequence, on the assumption the smaller numbers are less prone to mistakes on my part.)

If $n \equiv 1 \pmod{4}$ is positive, then we have the solution $$n = n + 1 + (-1) + \dots + 1 + (-1) = n \cdot 1 \cdot (-1) \cdots \cdot 1 \cdot (-1).$$

If $p \equiv 3 \pmod{4}$ is a positive prime, there are no solutions, as $$p = a_{1} \cdots a_{p-1} \cdot p$$ implies that an even number of the $a_{i}$ equals $-1$, but then for $$a_{1} + \dots + a_{p-1}$$ to be zero we need the same number of $a_{i}$ to be $1$, so $p-1$ would be a multiple of $4$, against the assumption.

If $n \equiv 0 \pmod 8$ is positive (i.e. $n = 8m$ for some positive integer $m$), then we have the solution

$$\underbrace{1 -1+\ldots + 1 -1}_{4m\text{ terms}} + \underbrace{1 + \ldots + 1}_{4m-2\text{ terms}} + 2 + 4m = \underbrace{1 \cdot (-1)\cdot\ldots \cdot 1 \cdot (-1)}_{4m\text{ terms}} + \underbrace{1 \cdot \ldots \cdot 1}_{4m-2\text{ terms}} \cdot 2 \cdot 4m$$

• Doesn't work the first case for $n\equiv 1\pmod{2}?$
– mfl
Dec 19, 2016 at 14:48
• @mfl not if you require $n > 0$ (you'd have an odd amount of $-1$s) Dec 19, 2016 at 14:50
• @DarthGeek Yes, right. Thank you
– mfl
Dec 19, 2016 at 14:51