login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A053616 Pyramidal sequence: distance to nearest triangular number. 3
0, 0, 1, 0, 1, 1, 0, 1, 2, 1, 0, 1, 2, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,9

LINKS

T. D. Noe, Table of n, a(n) for n = 0..1000

Index entries for sequences related to distance to nearest element of some set

EXAMPLE

a(12)=|12-10|=2 since 10 is the nearest triangular number to 12

MATHEMATICA

a[n_] := (k =.; k = Reduce[k > 0 && k*(k+1)/2 == n, Reals][[2]] // Floor; Min[(k+1)*(k+2)/2 - n, n - k*(k+1)/2]); Table[a[n], {n, 0, 104}] (* Jean-Fran├žois Alcover, Jan 08 2013 *)

Module[{trms=120, t}, t=Accumulate[Range[Ceiling[(Sqrt[8*trms+1]-1)/2]]]; Join[{0}, Flatten[Table[Abs[Nearest[t, n][[1]]-n], {n, trms}]]]] (* Harvey P. Dale, Nov 08 2013 *)

CROSSREFS

Cf. A000217, A002262, A053188.

Sequence in context: A170984 A114021 A239287 * A094718 A076191 A282318

Adjacent sequences:  A053613 A053614 A053615 * A053617 A053618 A053619

KEYWORD

easy,nice,nonn

AUTHOR

Henry Bottomley, Mar 20 2000

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy .

Last modified May 25 06:52 EDT 2018. Contains 304543 sequences. (Running on oeis4.)