Search All of the Math Forum:

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

Topic: List:{1}, {2,3},{4,5,6}....
Replies: 3   Last Post: Jan 11, 2013 10:24 PM

 Messages: [ Previous | Next ]
 Ray Koopman Posts: 3,383 Registered: 12/7/04
Re: List:{1}, {2,3},{4,5,6}....
Posted: Jan 11, 2013 10:23 PM

On Jan 10, 6:38 pm, hknetman <hknet...@hotmail.com> wrote:
> I use the command
> list = Table[i + 1, {n, 1, 5}, {i, n (n - 1)/2, n (n - 1)/2 + n - 1}]
> to get the following result:
> {{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}}
>
> Is there any better method?
>
> Thanks a lot.

I'm not sure what "better" means, but
here are the original and two others:

m = 5
Table[i+1,{n,m},{i,n(n-1)/2,n(n-1)/2+n-1}] (* original *)
Table[Range[1+n(n-1)/2,n(n+1)/2],{n,m}] (* clearest ? *)
Range[2+#*#-#,#*#+#,2]/2&/@Range@m (* shortest ? *)

5
{{1},{2,3},{4,5,6},{7,8,9,10},{11,12,13,14,15}}
{{1},{2,3},{4,5,6},{7,8,9,10},{11,12,13,14,15}}
{{1},{2,3},{4,5,6},{7,8,9,10},{11,12,13,14,15}}

Date Subject Author
1/11/13 mows
1/11/13 Ray Koopman
1/11/13 Ray Koopman