0
$\begingroup$

I am new to mathematica and I want to create the set of all n-tuples whose sum is less than a fixed number $N$. My idea would be to do a for loop where I choose first number $k_1$ in between 0 and N, then I choose my second number in between 0 and $N-k_1$, etc... At each step I have to check that $N-k_1-\dots-k_i\neq0$. If it is, the loop should break, the rest of the k's should be set to $0$ and the loop should restart. Is there anyway to code this efficiently in mathematica? Thus far, my only idea is to do Select[Tuples[Range[0, N], n], Sum[#] <= order &], which is highly inefficient.

$\endgroup$
2

0

Your Answer

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

Browse other questions tagged or ask your own question.