login
Partial sums of A082233 (read sequentially meandering).
2

%I #16 Sep 22 2013 17:28:17

%S 1,3,6,11,15,18,22,27,33,40,49,57,64,70,75,81,88,96,105,115,126,139,

%T 151,162,172,181,189,196,204,213,223,234,246,259,273,288,305,321,336,

%U 350,363,375,386,396,405,415,426,438,451,465,480,496

%N Partial sums of A082233 (read sequentially meandering).

%e A082233 begins:

%e 1,2,3,4,5,6,7,8,9,10

%e 3,4,5,6,7,8,9,10,11,12

%e 5,6,7,8,9,10,11,12,13,14

%e so this sequence begins 1, 1+2, 1+2+3, 1+2+3+5, 1+2+3+5+4, etc...

%p r:=0 ;

%p c:=1 ;

%p A082233 := proc(n,k)

%p 2*n+k ;

%p end proc:

%p A229035 := proc(n)

%p option remember;

%p global r,c ;

%p local d;

%p if n = 0 then

%p A082233(r,c) ;

%p else

%p d := r+c ;

%p if type(d,'odd') then

%p c := c+1 ;

%p r := r-1 ;

%p if r < 0 then

%p r :=0 ;

%p end if;

%p else

%p c := c-1 ;

%p r := r+1 ;

%p if c < 1 then

%p c :=1 ;

%p end if;

%p end if;

%p procname(n-1)+A082233(r,c) ;

%p end if;

%p end proc: # _R. J. Mathar_, Sep 21 2013

%o (JavaScript)

%o a=new Array();

%o for (i=0;i<10;i++) {

%o a[i]=new Array();

%o for (j=0;j<10;j++) a[i][j]=1+2*i+j;

%o }

%o for (i=0;i<10;i++) document.write(a[i]+'<br>');

%o document.write('<br>');

%o xp=0;yp=0;d=0;s=1;

%o document.write(s+", ");

%o for (i=0;i<4;i++) {

%o if (d==0) {xp++;d=1;s+=a[yp][xp];document.write(s+", ");}

%o if (d==1) {while (xp>0) {xp--;yp++;s+=a[yp][xp];document.write(s+", ");};d=2;}

%o if (d==2) {yp++;d=3;s+=a[yp][xp];document.write(s+", ");}

%o if (d==3) {while (yp>0) {xp++;yp--;s+=a[yp][xp];document.write(s+", ");};d=0;}

%o }

%Y Cf. A082233.

%K nonn

%O 1,2

%A _Jon Perry_, Sep 11 2013