login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A064289 Height of n-th term in Recamán's sequence A005132. 18
0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 7, 8, 7, 8, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

The height of a term in A005132 = number of addition steps - number of subtraction steps to produce it.

Partial sums of A160357. - Allan C. Wechsler, 08 Sep 2019

LINKS

Alois P. Heinz, Table of n, a(n) for n = 0..100000

Nick Hobson, Python program for this sequence

N. J. A. Sloane, FORTRAN program for A005132, A057167, A064227, A064228

Index entries for sequences related to Recamán's sequence

EXAMPLE

A005132 begins 1, 3, 6, 2, 7, 13, 20, 12, ... and these terms have heights 1, 2, 3, 2, 3, 4, 5, 4, ...

MAPLE

g:= proc(n) is(n=0) end:

b:= proc(n) option remember; local t;

      if n=0 then 0 else t:= b(n-1)-n; if t<=0 or g(t)

      then t:= b(n-1)+n fi; g(t):= true; t fi

    end:

a:= proc(n) option remember; `if`(n=0, 0,

       a(n-1)+signum(b(n)-b(n-1)))

    end:

seq(a(n), n=0..120);  # Alois P. Heinz, Sep 08 2019

MATHEMATICA

g[n_] := n == 0;

b[n_] := b[n] = Module[{t}, If[n == 0, 0, t = b[n - 1] - n; If[t <= 0 || g[t], t = b[n - 1] + n]; g[t] = True; t]];

a[n_] := a[n] = If[n == 0, 0, a[n - 1] + Sign[b[n] - b[n - 1]]];

a /@ Range[0, 100] (* Jean-François Alcover, Apr 11 2020, after Alois P. Heinz *)

CROSSREFS

Cf. A005132, A064288, A064290, A064292, A064293, A064294, A160357.

Sequence in context: A209302 A205122 A174863 * A078759 A276439 A282701

Adjacent sequences:  A064286 A064287 A064288 * A064290 A064291 A064292

KEYWORD

nonn,easy

AUTHOR

N. J. A. Sloane, Sep 25 2001

EXTENSIONS

a(0)=0 prepended by Allan C. Wechsler, 08 Sep 2019

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
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified July 13 04:31 EDT 2020. Contains 335673 sequences. (Running on oeis4.)