Re: Problem with nested for-loops



un.student@xxxxxxxxx writes:

Yesterday I came up with an interesting problem to which I'm unable to
provide any path for possible solutions.

Take n-tuple (a_1, ..., a_n) integers and create nested for loops as
int i = 0;
for b_1 from 1 to a_1
for b_2 from 1 to a_2
....
for b_n from 1 to a_n
i := i + 1

With given n-tuple this will produce some integer i. But if we are
given n and resulting i how would one find the n-tuple providing it?

Any ideas? Is this some known problem?

Study a few such tuples (a_1, ..., a_n) together with the product of
the a_k. Consider the uniqueness of a tuple that gives i.
.



Relevant Pages

  • Re: rolling dice
    ... int george; ... This n-tuple has to be lurking in the recursive function. ... sum by a struct with "x indicators" evaluated when you are at the ... unsigned long numberOfPossibleTuples; ...
    (comp.lang.c)
  • Re: rolling dice
    ... int countSomething; ... void enum_rec(int n, int m, int sum, int *pCount); ... This n-tuple has to be lurking in the recursive function. ...
    (comp.lang.c)