%I #35 Jul 27 2022 02:19:02
%S 1,1,2,2,3,4,4,5,6,7,7,8,9,10,11,11,12,13,14,15,16,16,17,18,19,20,21,
%T 22,22,23,24,25,26,27,28,29,29,30,31,32,33,34,35,36,37,37,38,39,40,41,
%U 42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,56,57,58,59,60,61,62,63,64,65,66,67,67,68,69,70,71,72,73,74,75,76,77,78,79,79,80,81,82,83,84,85,86,87
%N A P_3-stuttered arithmetic progression with a(n+1) = a(n) if n is a triangular number, a(n+1) = a(n) + 1 otherwise.
%C P_3(i) = the i-th triangular number.
%C As a triangle [1; 1,2; 2,3,4; ...], row sums = A064808: (1, 3, 9, 22, 45, 81, ...). - _Gary W. Adamson_, Aug 10 2007
%C a(n) = n - A003056(n-1). - _Reinhard Zumkeller_, Feb 12 2012
%H Reinhard Zumkeller, <a href="/A122797/b122797.txt">Table of n, a(n) for n = 1..10000</a>
%H Grady D. Bullington, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL10/Bullington/bullington7.html">The Connell Sum Sequence</a>, J. Integer Seq. 10 (2007), Article 07.2.6. (includes direct formula for a(n))
%H Douglas E. Iannucci and Donna Mills-Taylor, <a href="http://www.cs.uwaterloo.ca/journals/JIS/IANN/iann1.html">On Generalizing the Connell Sequence</a>, J. Integer Sequences, Vol. 2, 1999, #99.1.7.
%H J. W. Meijer and M. Nepveu, <a href="http://www.ucbcba.edu.bo/Publicaciones/revistas/actanova/documentos/v4n1/v4.n1.Meijer.pdf">Euler's ship on the Pentagonal Sea</a>, Acta Nova, Volume 4, No.1, December 2008. pp. 176-187. [From _Johannes W. Meijer_, Jun 21 2010]
%F a(n) = A001614(n) - n + 1.
%t nxt[{n_,a_}]:={n+1,If[OddQ[Sqrt[8n+1]],a,a+1]}; NestList[nxt,{1,1},100][[All,2]] (* _Harvey P. Dale_, Oct 10 2018 *)
%o (Haskell)
%o a122797 n = a122797_list !! (n-1)
%o a122797_list = 1 : zipWith (+) a122797_list (map ((1 -) . a010054) [1..])
%o -- _Reinhard Zumkeller_, Feb 12 2012
%o (PARI) isTriang(n) = {if (! issquare(8*n+1), return (0)); return (1);}
%o lista(m) = {aa = 1; for (i=1, m, print1(aa, ", "); if (! isTriang(i), aa = aa + 1););} \\ _Michel Marcus_, Apr 01 2013
%o (Python)
%o from math import isqrt
%o def A122797(n): return n+1-(k:=isqrt(m:=n<<1))-int((m<<2)>(k<<2)*(k+1)+1) # _Chai Wah Wu_, Jul 26 2022
%Y Cf. A001614, A122793, A122794, A122795, A122796, A122798, A122799, A122800.
%Y Cf. A064808.
%K nonn,easy
%O 1,3
%A Grady Bullington (bullingt(AT)uwosh.edu), Sep 14 2006
%E Definition corrected by _Michel Marcus_, Apr 01 2013