cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-3 of 3 results.

A340612 a(0) = 0; for n > 0, if n appears in the sequence then a(n) = 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.

Original entry on oeis.org

0, 1, 3, 2, 6, 11, 4, 11, 19, 10, 9, 7, 19, 32, 18, 33, 17, 16, 14, 12, 32, 53, 31, 8, 32, 57, 83, 56, 28, 57, 27, 22, 24, 15, 49, 84, 48, 85, 47, 86, 46, 5, 47, 90, 134, 89, 40, 42, 36, 34, 84, 135, 187, 21, 75, 20, 27, 29, 87, 146, 206, 145, 207, 144, 80, 145, 79, 146, 78, 147, 77, 148, 76, 149
Offset: 0

Views

Author

Scott R. Shannon, Jan 13 2021

Keywords

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 a(n) = lastindex(n), where lastindex(n) is the sequence index of the last appearance of n.
The terms appear to be clustered in bands which are themselves composed of thinner bands. No values appear outside these groupings. See the linked image.
The smallest value not to have appeared after 1 million terms is 13. It is unknown if all terms eventually appear.

Examples

			a(3) = 2, as a(2) = 3 = n, thus a(3) = 2.
a(5) = 11, as 5 has not previously appeared in the sequence, but 1 has, a(5) = a(4) + 5 = 6 + 5 = 11.
a(11) = 7, as a(7) = 11 = n, thus a(11) = 7.
		

Crossrefs

Programs

  • Python
    def aupton(nn):
      alst, index = [0], {0: 0} # data list, map of last occurrence
      for n in range(1, nn+1):
        if n in index:
          an = index[n]
        else:
          an = alst[-1] - n
          if an < 0 or an in index:
            an = alst[-1] + n
        alst.append(an)
        index[an] = n
      return alst
    print(aupton(65)) # Michael S. Branicky, Jan 13 2021

A340733 a(0) = 0; for n > 0, if the value of n itself appears in the sequence then a(n) = a(n-1) - (n-index(n)) if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + (n-index(n)), where index(n) is the index of the last appearance of n. If the value of n does not appear then a(n) = a(n-1) - n if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + n.

Original entry on oeis.org

0, 1, 3, 2, 6, 11, 9, 16, 8, 5, 15, 21, 33, 20, 34, 29, 38, 55, 37, 18, 25, 35, 13, 36, 12, 7, 33, 60, 32, 46, 76, 45, 41, 48, 28, 14, 27, 46, 24, 63, 23, 32, 74, 31, 75, 61, 52, 99, 84, 133, 83, 134, 128, 181, 127, 89, 145, 88, 30, 89, 56, 40, 102, 78, 142, 77, 143, 210, 278, 209, 139, 68
Offset: 0

Views

Author

Scott R. Shannon, Jan 17 2021

Keywords

Comments

This sequence 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 be n - index(n), where index(n) is the sequence index of the last appearance of n.
The sequence values appear random up to a(45256) = 45257. As 45257 has then appeared in the sequence the step size for the next term is 45257 - index(45257) = 45257 - 452576 = 1. As a(42564) = 45256 the next term a(45257) must be a(45256) + 1 = 45257 + 1 = 45258. This pattern then repeats so all terms beyond a(45256) are just a(n-1) + 1. See the linked image.

Examples

			a(3) = 2 as a(2) = 3 = n, thus the step size from a(2) is 3 - index(3) = 3 - 2 = 1. As 2 has not previously appeared a(3) = a(2) - 1 = 3 - 1 = 2.
a(6) = 9 as a(4) = 6 = n, thus the step size from a(5) is 6 - index(6) = 6 - 4 = 2. As 9 has not previously appeared a(6) = a(5) - 2 = 11 - 2 = 9.
		

Crossrefs

Programs

  • Python
    from itertools import count, islice
    def A340733_gen(): # generator of terms
        a, ndict = 0, {0:0}
        yield 0
        for n in count(1):
            yield (a:= (a-m if a>=(m:=n-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
    A340733_list = list(islice(A340733_gen(),30)) # Chai Wah Wu, Jun 29 2023

Formula

a(n) = n + 1 for n >= 45256.

A369829 a(0) = 0; for n > 0, if n appears in the sequence then a(n) = a(n-1) - sum of indexes where n appeared if that is nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + sum of indexes. Otherwise a(n) = a(n-1) - n if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + n.

Original entry on oeis.org

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, 2, 30, 61, 93, 76, 52, 87, 51, 14, 52, 13, 53, 94, 75, 54, 10, 33, 79, 32, 80, 31, 81, 117, 189, 149, 106, 161, 105, 48, 21, 80, 20
Offset: 0

Views

Author

Kelvin Voskuijl, Feb 02 2024

Keywords

Examples

			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.
a(29) = 2 as a(13) = 29 = n, and a(15) = 29, 13+15 is 28, thus the step size from a(2) is 28. As 2 has not previously appeared a(29) = a(29) - 28 = 30 - 28 = 2.
		

Crossrefs

Showing 1-3 of 3 results.