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-10 of 228 results. Next

A057167 Term in Recamán's sequence A005132 where n appears for first time, or -1 if n never appears.

Original entry on oeis.org

0, 1, 4, 2, 131, 129, 3, 5, 16, 14, 12, 10, 8, 6, 31, 29, 27, 25, 23, 99734, 7, 9, 11, 13, 15, 17, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 111, 22, 20, 18, 28, 30, 32, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196
Offset: 0

Views

Author

N. J. A. Sloane, Sep 14 2000

Keywords

Crossrefs

Programs

  • Maple
    w := array(1..10000); for j from 1 to 100 do l := 0; for k from 1 to nops(a) do if a[k] = j then l := k; exit; fi; od: w[j] := l; od: s := [seq(w[j],j=1..100)]; # where a is an array formed from sequence A005132
  • Mathematica
    A005132 = {0}; Do[If[(r = Last[A005132] - n) <= 0 || MemberQ[ A005132, r], r = r + 2n]; AppendTo[ A005132, r], {n, 1, 10^5}]; a[n_] := If[p = Position[ A005132, n]; p == {}, 0, p[[1, 1]] - 1]; Table[a[n], {n, 1, 60}] (* Jean-François Alcover, Jul 18 2012 *)
  • PARI
    first(n) = my(a=vector(n), r=[0]); while(#Set(a)Iain Fox, Jul 11 2022
    
  • Python
    from itertools import count, islice
    def agen(): # generator of terms
        an, A005132set, inv, y = 0, {0}, {0: 0}, 0
        for n in count(1):
            t = an - n
            an = t if t >= 0 and t not in A005132set else an + n
            A005132set.add(an)
            inv[an] = n
            while y in inv: yield inv[y]; y += 1
    print(list(islice(agen(), 61))) # Michael S. Branicky, Jul 12 2022

Extensions

I conjecture a(n) is never -1 - but see A064227, A064228.
a(0)=0 added and escape clause value changed to -1 by N. J. A. Sloane, May 01 2020

A064289 Height of n-th term in Recamán's sequence A005132.

Original entry on oeis.org

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
Offset: 0

Views

Author

N. J. A. Sloane, Sep 25 2001

Keywords

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, Sep 08 2019

Examples

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

Crossrefs

Programs

  • 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 *)

Extensions

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

A064227 From Recamán's sequence (A005132): record values in A057167.

Original entry on oeis.org

0, 1, 4, 131, 99734, 181653, 328002, 325374625245, 394178473633984
Offset: 1

Views

Author

N. J. A. Sloane, Sep 22 2001

Keywords

Comments

Let R(n) = n-th term of Recamán's sequence (A005132); consider values of R(n) that take a record number of steps to appear (A064228); sequence gives corresponding values of n.

Crossrefs

Extensions

a(8)-a(9) from Allan Wilks, Nov 06 2001
a(10) > 10^25. - Benjamin Chaffin, Jun 13 2006
a(10) > 4.28*10^73. - Benjamin Chaffin, Mar 22 2010
a(10) > 10^230. - Benjamin Chaffin, 2018
Initial term 0 added by N. J. A. Sloane, Feb 26 2023

A064290 First number of height n in Recamán's sequence A005132.

Original entry on oeis.org

0, 1, 3, 6, 13, 20, 43, 62, 113, 224, 367, 494, 833, 1815, 3379, 5551, 9169, 17864, 32978, 58964, 106218, 131313, 155719, 180118, 591890, 881467, 1345004, 3012446, 5728819, 9309579, 17512700, 25641318, 52978675, 61998980, 125130665, 244636214, 280766754, 566273517, 1031389697, 2182394227, 3045423658, 3454917187
Offset: 1

Views

Author

N. J. A. Sloane, Sep 25 2001

Keywords

Comments

The height of a term in A005132 = number of addition steps - number of subtraction steps to reach it (see A064289).
Needs a b-file. - N. J. A. Sloane, May 01 2020

Examples

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

Crossrefs

Extensions

a(0) = 0 added by N. J. A. Sloane, May 01 2020

A064389 Variation (4) on Recamán's sequence (A005132): to get a(n), we first try to subtract n from a(n-1): a(n) = a(n-1) - n if positive and not already in the sequence; if not then we try to add n: a(n) = a(n-1) + n if not already in the sequence; if this fails we try to subtract n+1 from a(n-1), or to add n+1 to a(n-1), or to subtract n+2, or to add n+2, etc., until one of these produces a positive number not already in the sequence - this is a(n).

Original entry on oeis.org

1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, 8, 25, 43, 62, 42, 63, 41, 18, 44, 19, 45, 72, 100, 71, 101, 70, 38, 5, 39, 4, 40, 77, 115, 76, 36, 78, 120, 163, 119, 74, 28, 75, 27, 79, 29, 80, 132, 185, 131, 186, 130, 73, 15, 81, 141, 202
Offset: 1

Views

Author

N. J. A. Sloane, Sep 28 2001

Keywords

Comments

This is the nicest of these variations. Is this a permutation of the natural numbers?
The number of steps before n appears is the inverse series, A078758. The height of n is in A126712.
See A078758 for the inverse permutation (in case this is a permutation of the positive integers). - M. F. Hasler, Nov 03 2014
After 10^12 terms, the smallest number which has not appeared is 5191516. - Benjamin Chaffin, Oct 09 2016

References

  • Suggested by J. C. Lagarias.

Crossrefs

Cf. A005132, A046901, A064387, A064388. Agrees with A064387 for first 187 terms, then diverges.

Programs

  • Maple
    h := array(1..100000); maxt := 100000; a := array(1..1000); a[1] := 1; h[1] := 1; for nx from 2 to 1000 do for i from 0 to 100 do t1 := a[nx-1]-nx-i; if t1>0 and h[t1] <> 1 then a[nx] := t1; if t1 < maxt then h[t1] := 1; fi; break; fi; t1 := a[nx-1]+nx+i; if h[t1] <> 1 then a[nx] := t1; if t1 < maxt then h[t1] := 1; fi; break; fi; od; od; evalm(a);
  • Mathematica
    h[1] = 1; h[] = 0; maxt = 100000; a[1] = 1; a[] = 0; For[nx = 2, nx <= 1000, nx++, For[i = 0, i <= 100, i++, t1 = a[nx - 1] - nx - i; If[t1 > 0 && h[t1] != 1, a[nx] = t1; If[t1 < maxt, h[t1] = 1]; Break[]]; t1 = a[nx - 1] + nx + i; If[h[t1] != 1, a[nx] = t1; If[t1 < maxt, h[t1] = 1]; Break[]]]]; Table[a[n], {n, 1, 100}](* Jean-François Alcover, May 09 2012, after Maple *)
  • PARI
    A064389(n=1000,show=0)={ my(k,s,t); for(n=1,n, k=n; while( !(t>k && !bittest(s, t-k) && t-=k) && !(!bittest(s, t+k)  && t+=k), k++); s=bitor(s,1<M. F. Hasler, Nov 03 2014

A160357 Sign of first differences of Recamán's sequence A005132.

Original entry on oeis.org

1, 1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, -1
Offset: 0

Views

Author

M. F. Hasler, Jun 03 2009

Keywords

Crossrefs

Programs

Formula

a(n) = sign(A005132(n)-A005132(n-1)) = sign(A160356(n)) = (-1)^A160351(n) = -(-1)^A076213(n-1).
a(n) = (A005132(n)-A005132(n-1))/n. - N. J. A. Sloane, Jul 15 2011
A160357 = chi_A057165 - chi_A057166, where chi_A denotes the characteristic function of (the set of values of) A.

Extensions

a(0)=1 added by N. J. A. Sloane, May 01 2020

A210606 Length of the n-th edge of an L-toothpick structure which gives Recamán's sequence A005132.

Original entry on oeis.org

1, 3, 5, 3, 4, 4, 5, 11, 13, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17
Offset: 1

Views

Author

Omar E. Pol, Mar 24 2012

Keywords

Comments

Consider a toothpick structure formed by L-toothpicks connected by their endpoints. The endpoints of the L-toothpicks are placed on the main diagonal of the first quadrant. At stage 1 we place an L-toothpick with one of its endpoints on the origin. At stage n we place an L-toothpick of size n. The L-toothpicks are placed alternately, on one or another sector of the first quadrant, trying to make the structure have an exposed endpoint closest to the origin. The total length of all L-toothpicks after the n-th stage is A002378(n). The value of x and y of the endpoint of the structure after the n-th stage is equal to the n-th term of Recamán's sequence A005132(n). Note that we can get other illustrations of initial terms of Recamán's sequence by replacing each L-toothpick by a Q-toothpick or by a semicircumference. This structure is also one of the three views of the three-dimensional model for Recamán's sequence. For more information about L-toothpicks and Q-toothpicks, see A172310 and A187210.

Examples

			The summands are the size of the L-toothpicks:
a(1) = 1.
a(2) = 1 + 2 = 3.
a(3) = 2 + 3 = 5.
a(4) = 3.
a(5) = 4.
a(6) = 4.
a(7) = 5.
a(8) = 5 + 6 = 11.
a(9) = 6 + 7 = 13.
a(10) = 7.
		

Crossrefs

A064228 From Recamán's sequence (A005132): values of n achieving records in A057167.

Original entry on oeis.org

0, 1, 2, 4, 19, 61, 879, 1355, 2406
Offset: 1

Views

Author

N. J. A. Sloane, Sep 22 2001

Keywords

Comments

If R(n) is the n-th term of Recamán's sequence (A005132), sequence gives values of R(n) that take a record number of steps to appear. A064227 gives corresponding values of n.

Crossrefs

Extensions

a(8) and a(9) from Allan Wilks, Nov 06 2001. After 10^15 terms of A005132, the smallest missing number was 852655.
After 10^25 terms of A005132 the smallest missing number is still 852655. - Benjamin Chaffin, Jun 13 2006
Even after 4.28*10^73 terms, the smallest missing number is still 852655. - Benjamin Chaffin, Mar 22 2010
Even after 10^230 terms, the smallest missing number is still 852655. - Benjamin Chaffin, 2018
Initial term 0 added by N. J. A. Sloane, Feb 26 2023

A064288 Height of n when it appears for first time in Recamán's sequence A005132.

Original entry on oeis.org

0, 1, 2, 2, 7, 7, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 18, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 19, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 19, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9
Offset: 0

Views

Author

N. J. A. Sloane, Sep 25 2001

Keywords

Comments

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

Examples

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

Crossrefs

Programs

  • C
    See Links section.

Extensions

a(0)=0 added by N. J. A. Sloane, May 01 2020

A064293 Last number of height n in Recamán's sequence A005132.

Original entry on oeis.org

1, 2, 7, 8, 14, 26, 4, 47, 92, 111, 181, 150, 371, 361, 781, 828, 366, 19, 61, 879, 4802, 3378, 5329, 9462, 32102, 18954, 18107, 16114, 4202, 25231, 60240, 92404, 92188, 14804
Offset: 1

Views

Author

N. J. A. Sloane, Sep 26 2001

Keywords

Comments

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

Crossrefs

Showing 1-10 of 228 results. Next