I am trying to Solve an equation like this:
$$ \sum _{i=1}^{\text{iMax}} (-i+\text{iMax}+1) n(i)=546 $$
Where all the $n(i)$ are can only take on the values 2,3,6,7, or 8.
I really have no idea how to tackle this problem. The only solution I have found thus far is for $\text{iMax} = 12$ and all $n(i)=7$:
iMax = 12;
nArr = Array[n, iMax];
eq = Sum[(iMax - i + 1) n[i], {i, iMax}] == 546;
fI = FindInstance[{eq, nArr < 8}, nArr, PositiveIntegers, 1]
(*{{n[1] -> 7, n[2] -> 7, n[3] -> 7, n[4] -> 7, n[5] -> 7, n[6] -> 7,
n[7] -> 7, n[8] -> 7, n[9] -> 7, n[10] -> 7, n[11] -> 7,
n[12] -> 7}}*)
For other values of iMax that aren't 12, solutions are generated in the positive integers, but the n[i] are not all 2,3,6,7, or 8.
possVals={2,3,6,7,8};
iMax = 13;
nArr = Array[n, iMax];
eq = Sum[(iMax - i + 1) n[i], {i, iMax}] == 546;
fI = FindInstance[{eq, nArr < 8}, nArr, PositiveIntegers, 1]
Complement[Flatten[nArr /. fI], possVals]
(*{{n[1] -> 7, n[2] -> 6, n[3] -> 7, n[4] -> 6, n[5] -> 6, n[6] -> 6,
n[7] -> 6, n[8] -> 5, n[9] -> 5, n[10] -> 5, n[11] -> 5, n[12] -> 4,
n[13] -> 4}}*)
(*{4, 5}*)
Asking for more solutions doesn't help, and is very slow:
iMax = 13;
nArr = Array[n, iMax];
eq = Sum[(iMax - i + 1) n[i], {i, iMax}] == 546;
fI = FindInstance[{eq, nArr < 8}, nArr, PositiveIntegers, 2]
Complement[Flatten[nArr /. #], possVals] & /@ fI
(*{{n[1] -> 7, n[2] -> 7, n[3] -> 6, n[4] -> 7, n[5] -> 3, n[6] -> 6,
n[7] -> 7, n[8] -> 4, n[9] -> 7, n[10] -> 5, n[11] -> 7, n[12] -> 5,
n[13] -> 1}, {n[1] -> 7, n[2] -> 5, n[3] -> 6, n[4] -> 7,
n[5] -> 4, n[6] -> 6, n[7] -> 7, n[8] -> 7, n[9] -> 7, n[10] -> 6,
n[11] -> 3, n[12] -> 7, n[13] -> 2}}*)
(*{{1, 4, 5}, {4, 5}}*)
Is there a way to ask FindInstance to search for solutions that are only made up of n[i] values being 2,3,6,7 or 8?
Or perhaps there is a way to do this with something else like IntegerPartitions?
n[i], not just the ones where all then[i]are the same number $\endgroup$