Subject: [mg124276] How to simplify this code with variable number of nesting loops?

From: Rex <aoirex at gmail.com>

Date: Sun, 15 Jan 2012 04:51:29 -0500 (EST)

Delivered-to: l-mathgroup@mail-archive0.wolfram.com

Considering an array a[i], i=0,1,...,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.