Hi,

I'd like to count the iterations of a loop nest by evaluating a sum.
Consider the following loop nest:

   for (k = 0; k < N; k++)
      for (i = k+1; i < N; i++)
          for (j = k+1; j <= i; j++)
             ...

I'd like to count the total number of iterations of that loop nest.
I've used mathematica a bit, and you could solve this problem with
something like this:

    Sum[1, {k, 0, N}, {i, k+1, N}, {j, k+1, i-1}]

The result should be in terms of N.  For this loop nest the closed
form is:

   1 / 6 * (1 + N) * (N^2 - N)

I've been trying to figure out how to do this sort of problem in Sage,
but I have been unsuccessful.  Any help would be greatly appreciated.

Thanks,
Patrick

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to