A064784 Difference between n-th triangular number t(n) and the largest square <= t(n).
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, 35, 24, 12, 44, 32, 19, 5, 41, 27, 12, 51, 36, 20, 3, 46, 29, 11, 57, 39, 20, 0, 50, 30, 9, 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
Offset: 1
Examples
n = 5: A000217(5) = 28, largest square below that is 25, so a(5) = 28 - 25 = 3.
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.
- Index entries for sequences related to EKG sequence
Programs
-
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 *)
-
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
Formula
a(n) = n*(n+1)/2 - floor(sqrt(n*(n+1)/2))^2.
a(A001108(n)) = 0. - Hugo Pfoertner, Jun 01 2024
Extensions
Definition corrected by Harry J. Smith, Sep 25 2009
Terms corrected by Harry J. Smith, Sep 25 2009
Comments