The OEIS is supported by the many generous donors to the OEIS Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A340593 a(0) = 0; for n > 0, if n appears in the sequence then a(n) = a(n-1) - lastindex(n) if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + lastindex(n), where lastindex(n) is the index of the last appearance of n. Otherwise a(n) = a(n-1) - n if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + n. 2
 0, 1, 3, 5, 9, 6, 11, 4, 12, 8, 18, 24, 16, 29, 15, 29, 17, 33, 23, 42, 22, 43, 63, 45, 34, 59, 85, 58, 30, 45, 73, 104, 72, 55, 31, 66, 102, 65, 27, 66, 26, 67, 48, 69, 25, 54, 100, 53, 95, 46, 96, 147, 199, 152, 107, 74, 130, 187, 160, 135, 75, 14, 76, 98, 162, 125, 86, 127, 195, 238, 168, 97 (list; graph; refs; listen; history; text; internal format)
 OFFSET 0,3 COMMENTS This sequences uses the same rules as Recamán's sequence A005132 if the value of n itself has not previously appeared in the sequence. However if n has previously appeared then the step size from a(n-1) is set to lastindex(n), where lastindex(n) is the sequence index of the last appearance of n. The smallest value not to have appeared after 1 million terms is 52. It is unknown if all terms eventually appear. LINKS Table of n, a(n) for n=0..71. EXAMPLE a(3) = 5 as a(2) = 3 = n, thus the step size from a(2) is 2. As 1 has previously appeared a(3) = a(2) + 2 = 3 + 2 = 5. a(5) = 6 as a(3) = 5 = n, thus the step size from a(4) is 3. As 6 has not previously appeared a(5) = a(4) - 3 = 9 - 3 = 6. PROG (Python) from itertools import count, islice def A340593_gen(): # generator of terms a, ndict = 0, {0:0} yield 0 for n in count(1): yield (a:= (a-m if a>=(m:=ndict[n]) and a-m not in ndict else a+m) if n in ndict else (a-n if a>=n and a-n not in ndict else a+n)) ndict[a] = n A340593_list = list(islice(A340593_gen(), 30)) # Chai Wah Wu, Jun 29 2023 CROSSREFS Cf. A005132, A339673, A340612, A336760, A336761. Sequence in context: A231736 A212437 A048639 * A021282 A016613 A336849 Adjacent sequences: A340590 A340591 A340592 * A340594 A340595 A340596 KEYWORD nonn AUTHOR Scott R. Shannon, Jan 13 2021 STATUS approved

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

Last modified February 26 19:43 EST 2024. Contains 370352 sequences. (Running on oeis4.)