Generating all possible sums given an integer $N$

40 Views Asked by At

Assume that $N$ and $M$ are given natural numbers. Is it easy to find the number of increasing sequence $a_i$'s (or even better, generating all possible $a_i$'s) such that $$N=\sum_{i=0}^M i\cdot a_i$$ where $a_i$ are digits, i.e. $0\leq a_i\leq 9$? Would that correspond to something similar to base arithmetic? Sadly, I have no idea on how to proceed.