login
a(1)=1, then if n not a square a(n)=a(n-1) + n, if n a square then a(n)= a(n-1) - n.
2

%I #5 Jul 10 2017 14:25:37

%S 1,3,6,2,7,13,20,28,19,29,40,52,65,79,94,78,95,113,132,152,173,195,

%T 218,242,217,243,270,298,327,357,388,420,453,487,522,486,523,561,600,

%U 640,681,723,766,810,855,901,948,996,947,997,1048,1100,1153,1207,1262,1318

%N a(1)=1, then if n not a square a(n)=a(n-1) + n, if n a square then a(n)= a(n-1) - n.

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

%e a(1)=1

%e As 2 not a square a(2)=1+2=3

%e As 3 not a square a(3)=3+3=6

%e As 4 is a square a(4)=6-4=2

%t nxt[{n_,a_}]:={n+1,If[IntegerQ[Sqrt[n+1]],a-(n+1),a+(n+1)]}; NestList[nxt,{1,1},60][[All,2]] (* _Harvey P. Dale_, Jul 10 2017 *)

%K easy,nonn

%O 1,2

%A _Pierre CAMI_, Sep 28 2004