OFFSET
1,2
COMMENTS
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, ...
LINKS
Harry J. Smith, Table of n, a(n) for n = 1..1000
J. C. Lagarias, E. M. Rains and N. J. A. Sloane, The EKG sequence, Exper. Math. 11 (2002), 437-446.
J. C. Lagarias, E. M. Rains and N. J. A. Sloane, The EKG sequence, arXiv:math/0204011 [math.NT], 2002.
FORMULA
a(n) = n*(n+1)/2 - floor(sqrt(n*(n+1)/2))^2.
a(A001108(n)) = 0. - Hugo Pfoertner, Jun 01 2024
EXAMPLE
n = 5: A000217(5) = 28, largest square below that is 25, so a(5) = 28 - 25 = 3.
MAPLE
seq(n*(n+1)/2-floor(sqrt(n*(n+1)/2))^2, n=0..100);
MATHEMATICA
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 *)
#-Floor[Sqrt[#]]^2&/@Accumulate[Range[100]] (* Harvey P. Dale, Oct 15 2014 *)
PROG
(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
(Python)
from math import isqrt
def A064784(n): return (m:=n*(n+1)>>1)-isqrt(m)**2 # Chai Wah Wu, Jun 01 2024
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Jonathan Ayres (jonathan.ayres(AT)btinternet.com), Oct 20 2001
EXTENSIONS
Definition corrected by Harry J. Smith, Sep 25 2009
Terms corrected by Harry J. Smith, Sep 25 2009
STATUS
approved