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!)
A308419 Stopping time for Recamán-like iteration of each n: a(0) = n, a(k) = a(k-1) - k if positive and not already in the sequence, a(k) = a(k-1) + k if not already in the sequence, otherwise stop. 1
24, 24, 13, 21, 3, 3, 3, 15, 6, 6, 6, 15, 12, 9, 9, 9, 16, 20, 15, 12, 12, 12, 8, 10, 12, 20, 15, 15, 15, 10, 15, 24, 22, 26, 18, 18, 18, 11, 13, 18, 29, 28, 27, 21, 21, 21, 15, 13, 19, 17, 25, 31, 23, 24, 24, 24, 16, 18, 20, 21 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,1

COMMENTS

a(0) is the index of the first repeated value in Recamán's sequence (A005132).

a(n) appears to grow like sqrt(2n).

LINKS

Table of n, a(n) for n=0..59.

EXAMPLE

For n = 8, the Recamán-like sequence generated is 8, 7, 5, 2, 6, 1; the sequence halts after a(8) = 6 terms since 1 - 6 = -5 is negative and 1 + 6 = 7 is already in the sequence.

PROG

(Python 3)

def seqr(n):

    sequence = [n]

    i = 1

    while True:

        if n - i > 0 and n - i not in sequence:

            n -= i

            sequence.append(n)

        elif n + i not in sequence:

            n += i

            sequence.append(n)

        else:

            break

        i += 1

    return len(sequence)

print([seqr(n) for n in range(1000)])

CROSSREFS

Iteration rule nearly identical to A005132.

A334219 is essentially the same sequence.

Sequence in context: A022980 A023466 A278656 * A010863 A217140 A235249

Adjacent sequences:  A308416 A308417 A308418 * A308420 A308421 A308422

KEYWORD

nonn

AUTHOR

Kevin J. Gomez, May 25 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 September 17 12:00 EDT 2021. Contains 347477 sequences. (Running on oeis4.)