Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » sci.math.* » sci.math.symbolic.independent

Topic: How to do variable number of nesting loops?
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Rex

Posts: 23
Registered: 10/13/10
How to do variable number of nesting loops?
Posted: Jan 14, 2012 11:13 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Considering an array a[i], i=0,1,2,...,g, where g could be any given
number, and a[0]=1.


for a[1]=a[0]+1 to 1 do
for a[2]=a[1]+1 to 3 do
for a[3]=a[2]+1 to 5 do
......
for a[g]=a[g-1]+1 to 2g-1 do
###some computations here###


The problem is that everytime we change the value of g, we need to
modify the code, those loops above. So this is not a good code.

Any advice would be greatly appreciated. Languages such as
Mathematica, Matlab, Maple, C/C++, or Fortran is fine.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.