[go: up one dir, main page]

login
Start with 1, add 1, subtract 2, multiply by 3, add 4, subtract 5, multiply by 6, add 7, etc.
1

%I #16 Sep 29 2024 21:09:50

%S 1,2,0,0,4,-1,-6,1,-7,-63,-53,-64,-768,-755,-769,-11535,-11519,-11536,

%T -207648,-207629,-207649,-4360629,-4360607,-4360630,-104655120,

%U -104655095,-104655121,-2825688267,-2825688239,-2825688268,-84770648040,-84770648009

%N Start with 1, add 1, subtract 2, multiply by 3, add 4, subtract 5, multiply by 6, add 7, etc.

%H Harvey P. Dale, <a href="/A252729/b252729.txt">Table of n, a(n) for n = 1..1000</a>

%p A252729 := proc(n)

%p option remember;

%p if n =1 then

%p 1;

%p elif modp(n,3) = 2 then

%p procname(n-1)+n-1;

%p elif modp(n,3) = 0 then

%p procname(n-1)-(n-1);

%p elif modp(n,3) = 1 then

%p procname(n-1)*(n-1);

%p fi ;

%p end proc:

%p seq(A252729(n),n=1..32) ; # _R. J. Mathar_, Mar 20 2015

%t nxt[{n_,a_}]:={n+1,Which[Mod[n+1,3]==1,a+n+1,Mod[n+1,3]==2,a-(n+1),True, a*(n+1)]}; Transpose[NestList[nxt,{0,1},35]][[2]] (* _Harvey P. Dale_, Mar 29 2015 *)

%o (Liberty BASIC)

%o input "How many terms? ";nt:a=1

%o 1 print a;",";:n=n+1:a=a+n

%o print a;",";:n=n+1:a=a-n

%o print a;",";:n=n+1:a=a*n

%o if n<nt then goto 1 else end

%K sign,easy

%O 1,2

%A _Edwin McCravy_, Dec 20 2014