 <p>Partial answer:</p> <p>Try all permutations of all subsets of your digits, probably starting with the largest candidates.</p> <p>If your factors contain <code>5</code> the <em>last</em> digit must be <code>0</code>or <code>5</code></p> <p>If your factors contain <code>3</code> or <code>6</code> or <code>9</code> the sum of all candidate digits muts be a multiple of <code>3</code></p> <p>If your factors contain 2 or 4 or 6 or 8 the last digit must be even.</p> <p>And so on.</p>