I need to find growing combinations of variables a, b, c etc. I don't know names of math things in English well, so my description of the problem will be in pseudocode. This is for a programming problem, but I want to understand the underlying mathematics. I would highly appreciate proper names of techniques used so I can look them up further.

Lets say we have a list of variables

L (a, b, c)

And one single variable l which is the maximum desired count of a single variable from L.

I need to find every combination of elements from L multiplied by numbers from 0 to l.

So, for l = 3 I expect the following result:


... and so on until ...


1 Answer 1


You can think of these combinations as 3-digit numbers in base $l+1$. For example, if $l=9$ then the solutions to your problem are in one-to-one correspondence with 3-digit decimal numbers, from 000 to 999. There are in total $(l+1)^3$ of them.

As an aside, it is not clear why you omitted 0a0b0c.

  • $\begingroup$ Thank you Yuval, I would not have thought of that! $\endgroup$
    – Dreen
    Commented Nov 26, 2017 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.