Deriving a formula/algorithm to find all integers with n digits (abcd...) where a+b+c+d... = a × b × c × d... a+b+c+d...  = a × b × c × d...
The sum of the digits equals the product of the digits.
I'm currently creating a program in c++ where the user inserts a lower limit m, and a upper limit n. The program then finds all the integers, k, where the statement above is true and m <= k <= n. I've tried to achieve this in a couple of ways. The first way is just running through all integers between m and n and check if the above statement is true for every integer. This works well for the lower numbers, but obviously fails with larger values for m and n. I've also tried to make the previous approach more effective by for example skipping numbers where some of the digits equals zero, because then the sum will obviously be larger than the product. But this didn't do it. 
I then moved on to try and find an algorithm or formula that would give me all the permutations where the above statement is true for an integer of n digits. I've not been able to do this, and I've also tried to search around on this forum. I found a post where a user asked for help to find out how many 4 digit numbers there is where the above statement is true. A user replied that he had seen a pattern, and that a formula for finding the permutations could be:
a = (b+n-2)/(b-1) 
Where n is the amount of digits in the integer, and we're assuming that there will be n-2 1's in the integer. a and b are numbers between 2 and 9.
For a 4 digit integer we find that this is true for a = {2,4} and b = {2,4}.
There are 6 permuations of these digits, and therefore there are 6 four digit numbers where a + b + c + d = a × b × c × d
However, the formula doesn't give all the answers for larger numbers. For example a 5 digit number. 11222 is a 5 digit number  where the above statement is true, but the formula will not give this number.
Thanks for the help!
 A: Two obsevations that reduce the search space significantly:


*

*You can assume the digits are in (weakly) increasing order, then do all the permutations of the numbers you have found. 

*If there are $n$ digits, the sum is between $n$ and $9n$


Now loop starting with the last digit.  For example, if $n=6$ and the last digit is $9$, the sum is no larger than $54$, so the next to last digit cannot be larger than $6$.  You quickly find that $xxxx69$ doesn't work.  When the last digit is $8$, the sum is not larger than $8n$, here $48$. Again the next to last digit is no greater than $6$ (in general, it is no larger than $n$).  You will run out of possibilities quickly.
A: Doh!
Take any a,b,c,d...n all greater than 1.  Then add abcd...n - a - b - c -d - .... -n ones.  The product will be abcd...n  and the sum will be too.
So for example if I take 3,5 then 111111135 (which has 3 x 5 - 3 - 5 = 15 - 8 = 7 ones) will have a product 15 an a sum of 3 +5 + 7 = 15.
22 and zero ones work.  That's the only multidigit one with no 1s.  
6841111....111 will work if there are (6*8*4 - 6 - 8 - 4) ones.
=====
The only real issue is how do we know that the product of digits greater than one is always greater than the sum of the digits greater than one?
Let $a,b,c,d,...$ all be greater than 1. Then:
$abcd.... = a + a(bcd.... - 1) \ge a + 2(bcd... - 1) = (a + bcd...) + (bcd... - 2) \ge a + bcd .....$
with equality holding only if $a = 2; b=2$ and there are only two digits. 
Inductively (if there are more than two digits) we get:
$abcd... > a + bcde.... > a + b + cdef.... > a + b + c + ..... + n$
====
So:
case 1: one of the digits is zero
$a + b + c + ... = abcd... = 0 \implies $ all terms = 0.
So $0$ is a solution.  No other will have a $0$ terms.
case 2: there is one digit.
$a = a$; there are (not including $0$) 9 options.
case 3: there are at least two digits and none of them are $0$ or $1$
$22 = 2 + 2$ is only option by above.
case 4: all else
by above: the product of non-one terms is greater than the sum of non-one terms so a number will be a solution if and only if the number of one terms is equal to the product of non-one terms minus the sum of non-one terms. 
