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-7 of 7 results.

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.

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, 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
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 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.

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.
		

Crossrefs

Programs

  • 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

A362332 For n > 1, 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+1) = a(n)/(n+1) if (n+1)|a(n), otherwise a(n)*(n+1), a(1) = 1 and a(2) = 1*2.

Original entry on oeis.org

1, 2, 6, 24, 120, 3, 21, 168, 1512, 15120, 166320, 13860, 180180, 12870, 858, 13728, 233376, 4200768, 79814592, 1596291840, 7, 154, 3542, 4, 100, 2600, 70200, 1965600, 57002400, 1900080, 58902480, 1884879360, 62201018880
Offset: 1

Views

Author

Kelvin Voskuijl, Apr 16 2023

Keywords

Examples

			a(2) = 2, as a(1) = 1 and 1 times 2 is 2.
a(6) = 3, as a(3) = 6 = n, thus a(6) = 3.
a(7) = 21, as a(6) = 3 and 3 times 7 is 21.
		

Crossrefs

Programs

A362373 a(0) = 0; for n > 0, if n appears in the sequence then a(n) is the sum of the indices of all previous appearances 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, 12, 11, 24, 38, 23, 7, 24, 42, 8, 28, 49, 27, 15, 30, 5, 31, 22, 20, 49, 24, 26, 58, 25, 59, 94, 130, 93, 14, 53, 13, 54, 18, 61, 17, 62, 16, 63, 111, 50, 49, 100, 48, 39, 41, 96, 40, 97, 32, 34, 94
Offset: 0

Views

Author

Kelvin Voskuijl, Apr 17 2023

Keywords

Comments

Conjecture: All nonnegative integers appear in this sequence. - Yifan Xie, Apr 24 2023

Examples

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

Crossrefs

Programs

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.

A362698 For n > 1, if n appears in the sequence, a(n) = a(n-1) - n if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + n. Otherwise a(n+1) = a(n)/(n+1) if (n+1)|a(n), otherwise a(n)*(n+1), a(1) = 1 and a(2) = 1*2.

Original entry on oeis.org

1, 2, 6, 24, 120, 114, 798, 6384, 57456, 574560, 6320160, 526680, 6846840, 489060, 32604, 521664, 8868288, 159629184, 8401536, 168030720, 3528645120, 160392960, 3689038080, 3689038056, 92225951400, 2397874736400, 64742617882800, 1812793300718400, 52571005720833600
Offset: 1

Views

Author

Kelvin Voskuijl, Jul 07 2023

Keywords

Examples

			a(2) = 2, as a(1) = 1 and 1 times 2 is 2.
a(6) = 114, as a(3) = 6 = n, thus a(6) = a(5) - 6 =  114.
a(7) = 798, as a(6) = 114 and 7 times 114 is 798.
		

Crossrefs

Programs

Extensions

More terms from Michael De Vlieger, Aug 30 2023

A363962 a(1)=1; for n > 1, 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 unless that result is already in the sequence or would be negative; otherwise, a(n) = a(n-1) * n.

Original entry on oeis.org

1, 2, 6, 24, 19, 3, 21, 13, 4, 40, 29, 17, 8, 112, 97, 81, 12, 216, 5, 100, 7, 154, 131, 4, 100, 74, 47, 1316, 11, 330, 299, 267, 234, 200, 165, 129, 92, 54, 15, 10, 410, 368, 325, 281, 236, 190, 27, 1296, 1247, 1197, 1146, 1094, 1041, 38, 2090, 2034, 1977, 1919, 1860, 1800, 1739, 1677, 1614
Offset: 1

Views

Author

Kelvin Voskuijl, Jun 29 2023

Keywords

Examples

			a(6) = 3, as a(3) = 6 = n, thus a(6) = 3.
a(28) = 1316 because subtracting 28 from the previous term (47) would give 19, which is already in the sequence, so multiply 47 by 28 to get 1316.
a(100) = 25, as a(25) = 100 = n, thus a(100) = 25.
		

Crossrefs

Programs

  • MATLAB
    function a = A363962( max_n )
        a = 1;
        for n = 2:max_n
            r = find(a == n,1,'last');
            if ~isempty(r)
                a(n) = r;
            else
                k = a(n-1) - n;
                if k > 0 && isempty(find(a == k, 1))
                    a(n) = k;
                else
                    a(n) = a(n-1) * n;
                end
            end
        end
    end % Thomas Scheuerle, Jul 03 2023
  • Mathematica
    a[1] = 1; a[n_] := a[n] = Module[{s = Array[a, n - 1], a1}, If[MemberQ[s, n], Position[s, n][[-1, 1]], a1 = a[n - 1] - n; If[a1 < 0 || MemberQ[s, a1], a[n - 1]*n, a1]]]; Array[a, 100] (* Amiram Eldar, Jul 23 2023 *)

A364929 a(0) = 0; for n > 0, if n appears in the sequence then a(n) is the product of the indices of all previous appearances 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, 35, 23, 36, 22, 7, 23, 40, 58, 8, 28, 49, 14, 192, 168, 143, 117, 90, 20, 49, 79, 48, 16, 49, 15, 11, 13, 50, 12, 51, 17, 58, 100, 57, 101, 56, 102, 55, 31, 20097, 37, 39, 91, 38, 92, 47, 45, 43, 738, 679, 619, 558, 496, 433, 369
Offset: 0

Views

Author

Kelvin Voskuijl, Dec 05 2023

Keywords

Examples

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

Crossrefs

Programs

  • PARI
    See PARI link
    
  • Python
    from itertools import count, islice
    def agen(): # generator of terms
        an, p = 0, {0: 0} # data list, map of product of indices
        for n in count(1):
            yield an
            an = p[n] if n in p else an+n if an-n < 0 or an-n in p else an-n
            p[an] = p[an]*n if an in p else n
    print(list(islice(agen(), 65))) # Michael S. Branicky, Dec 09 2023

Extensions

More terms from David A. Corneth, Dec 09 2023
Showing 1-7 of 7 results.