%I #37 Jun 01 2024 12:04:40
%S 0,2,2,1,6,5,3,0,9,6,2,14,10,5,20,15,9,2,21,14,6,28,20,11,1,27,17,6,
%T 35,24,12,44,32,19,5,41,27,12,51,36,20,3,46,29,11,57,39,20,0,50,30,9,
%U 62,41,19,75,53,30,6,66,42,17,80,55,29,2,69,42,14,84,56,27,100,71,41,10,87,56
%N Difference between n-th triangular number t(n) and the largest square <= t(n).
%C The second differences of a(n) - (a(n)-a(n-1))-(a(n-1)-a(n-2)) - give 2, -2, -1, 6, -6, -1, -1, 12, -12, -1, 16, -16, -1 ... 82k+2, 82k-2, -1, 82k+6, 82k-6, -1, -1, 82k+12, 82k-12, -1, 82k+16, -82k-16, -1, 82k+20, -82k-20, -1, -1, 82k+26, -82k-26, -1, 82k+30, -82k-30, -1, -1, 82k+36, -82k-36, -1, 82k+40, -82k-40, -1, 82k+44, -82k-44, -1, -1, 82k+50, -82k-50, -1, 82k+54, -82k-54, -1, -1, 82k+60, -82k-60, -1, 82k+64, -82k-64, -1, -1, 82k+70, -82k-70, -1, 82k+74, -82k-74, -1, 82k+78, -82k-78, -1, -1, ...
%H Harry J. Smith, <a href="/A064784/b064784.txt">Table of n, a(n) for n = 1..1000</a>
%H J. C. Lagarias, E. M. Rains and N. J. A. Sloane, <a href="http://www.emis.de/journals/EM/expmath/volumes/11/11.3/Lagarias437_446.pdf">The EKG sequence</a>, Exper. Math. 11 (2002), 437-446.
%H J. C. Lagarias, E. M. Rains and N. J. A. Sloane, <a href="https://arxiv.org/abs/math/0204011">The EKG sequence</a>, arXiv:math/0204011 [math.NT], 2002.
%H <a href="/index/Ed#EKG">Index entries for sequences related to EKG sequence</a>
%F a(n) = n*(n+1)/2 - floor(sqrt(n*(n+1)/2))^2.
%F a(n) = A053186(A000217(n)). - _R. J. Mathar_, Sep 10 2016
%F a(A001108(n)) = 0. - _Hugo Pfoertner_, Jun 01 2024
%e n = 5: A000217(5) = 28, largest square below that is 25, so a(5) = 28 - 25 = 3.
%p seq(n*(n+1)/2-floor(sqrt(n*(n+1)/2))^2,n=0..100);
%t f[n_]:=n*(n+1)/2-Floor[Sqrt[n*(n+1)/2]]^2; lst={}; Do[AppendTo[lst,f[n]],{n,0,6!}]; lst (* _Vladimir Joseph Stephan Orlovsky_, Feb 17 2010 *)
%t #-Floor[Sqrt[#]]^2&/@Accumulate[Range[100]] (* _Harvey P. Dale_, Oct 15 2014 *)
%o (PARI) { default(realprecision, 100); for (n=1, 1000, t=n*(n + 1)/2; a=t - floor(sqrt(t))^2; write("b064784.txt", n, " ", a) ) } \\ _Harry J. Smith_, Sep 25 2009
%o (Python)
%o from math import isqrt
%o def A064784(n): return (m:=n*(n+1)>>1)-isqrt(m)**2 # _Chai Wah Wu_, Jun 01 2024
%Y Cf. A001108, A076816, A128549, A230038. Unique values are in A230044.
%K nonn,look
%O 1,2
%A Jonathan Ayres (jonathan.ayres(AT)btinternet.com), Oct 20 2001
%E Definition corrected by _Harry J. Smith_, Sep 25 2009
%E Terms corrected by _Harry J. Smith_, Sep 25 2009