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.

Previous Showing 11-20 of 37 results. Next

A081688 0 followed by A030124 - 1.

Original entry on oeis.org

0, 1, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 70, 71, 72, 73, 74, 75, 76, 77
Offset: 0

Views

Author

N. J. A. Sloane, Apr 02 2003

Keywords

Comments

From P-positions in a certain game.
The rule "monotonically increasing sequence where the size of each run of consecutive integers is given by the sequence itself" produces this sequence without the initial 0. - Eric Angelini, Aug 19 2008

Crossrefs

Formula

Let a(n) = this sequence, b(n) = A081689. Then a(n) = mex{ a(i), b(i) : 0 <= i < n}, b(n) = b(n-1) + a(n) + 1. Apart from initial zero, complement of A081689.

A037257 a() = 1,3,... [ A037257 ], differences = 2,... [ A037258 ] and 2nd differences [ A037259 ] are disjoint and monotonic; adjoin next free number to 2nd differences unless it would produce a duplicate in which case ignore.

Original entry on oeis.org

1, 3, 9, 20, 38, 64, 100, 148, 209, 284, 374, 480, 603, 745, 908, 1093, 1301, 1533, 1790, 2075, 2389, 2733, 3108, 3515, 3955, 4429, 4938, 5484, 6069, 6694, 7360, 8068, 8819, 9614, 10454, 11340, 12273, 13255, 14287, 15370, 16505, 17693, 18935, 20232
Offset: 0

Views

Author

Keywords

Comments

27 and 250 are the first two numbers to be ignored.
I discovered this around 1979; Martin Gardner described a version of it in his 1980 article.

Examples

			After 1 3 9 20 with differences
------ 2 6 11 and 2nd differences
------- 4 5, the next free number is 7 so we get
----- 1 3 9 20 38 ...
------ 2 6 11 18 ...
------- 4 5 7 ....
		

References

  • M. Gardner, Weird Numbers from Titan, Isaac Asimov's Science Fiction Magazine, Vol. 4, No. 5, May 1980, pp. 42ff.

Crossrefs

Programs

  • Mathematica
    ClearAll[a]; A037257 = {a[0]=1, a[1]=3, a[2]=9}; d1 = Differences[A037257]; d2 = Differences[d1]; ignored = {}; a[n_] := a[n] = (u = Union[A037257, d1, d2, ignored]; m = MapIndexed[List, u]; sel = Select[m, #1[[1]] != #1[[2, 1]] & , 1]; For[nextFree = sel[[1, 2, 1]], True, nextFree++, an2 = nextFree; an = an2 - a[n-2] + 2*a[n-1]; an1 = an - a[n-1]; If[ FreeQ[ ignored, an2] && Length[ Join[ A037257, d1, d2, {an, an1, an2}]] == Length[ Union[ A037257, d1, d2, {an, an1, an2}]], Break[], AppendTo[ ignored, an2]] ]; AppendTo[ A037257, an]; AppendTo[d1, an1]; AppendTo[d2, an2]; an); Table[a[n], {n, 0, 43}] (* Jean-François Alcover, Sep 14 2012 *)

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Sep 25 2000

A167151 a(2n+1) = a(2n) + a(2n-1), a(2n)=least number not yet in the sequence, a(1)=1.

Original entry on oeis.org

0, 1, 2, 3, 4, 7, 5, 12, 6, 18, 8, 26, 9, 35, 10, 45, 11, 56, 13, 69, 14, 83, 15, 98, 16, 114, 17, 131, 19, 150, 20, 170, 21, 191, 22, 213, 23, 236, 24, 260, 25, 285, 27, 312, 28, 340, 29, 369, 30, 399, 31, 430, 32, 462, 33, 495, 34, 529, 36, 565, 37, 602, 38, 640, 39, 679
Offset: 0

Views

Author

M. F. Hasler, Nov 01 2009

Keywords

Comments

Lexicographically earliest reordering of the nonnegative integers (can be extended by symmetry to a permutation of all integers) such that a(2n+1) = a(2n) + a(2n-1).

Crossrefs

Cf. A225850 (inverse).

Programs

  • Haskell
    import Data.List (transpose)
    a167151 n = a167151_list !! n
    a167151_list = 0 : concat (transpose [a005228_list, a030124_list])
    -- Reinhard Zumkeller, May 17 2013
  • Mathematica
    a[0] = 0; a[1] = 1;
    a[n_?OddQ] := a[n] = a[n - 1] + a[n - 2];
    a[n_?EvenQ] := a[n] = For[k = 2, True, k++,
         If[FreeQ[Array[a, n - 1], k], Return[k]]];
    Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Dec 02 2021 *)
  • PARI
    {used=[]; print1(b=0); a=1; for(i=1,99, used=setunion(used,Set(a+=b)); while(setsearch(used,b++), used=setminus(used,Set(b))); print1(", "a", "b))}
    

Formula

a(2n-1) = A005228(n); a(2n) = A030124(n).

A225376 Construct sequences P,Q,R by the rules: Q = first differences of P, R = second differences of P, P starts with 1,5,11, Q starts with 4,6, R starts with 2; at each stage the smallest number not yet present in P,Q,R is appended to R; every number appears exactly once in the union of P,Q,R. Sequence gives P.

Original entry on oeis.org

1, 5, 11, 20, 36, 60, 94, 140, 199, 272, 360, 465, 588, 730, 893, 1078, 1286, 1519, 1778, 2064, 2378, 2721, 3094, 3498, 3934, 4403, 4907, 5448, 6027, 6645, 7303, 8002, 8743, 9527, 10355, 11228
Offset: 1

Views

Author

N. J. A. Sloane, May 12 2013, based on email from Christopher Carl Heckman, May 06 2013

Keywords

Comments

P can be extended for 10^6 terms, but it is not known if P,Q,R can be extended to infinity.
A probabilistic argument suggests that P, Q, R are infinite. - N. J. A. Sloane, May 19 2013
Martin Gardner (see reference) states that no such triple P,Q,R of sequences exists if it is required that P(1)

Examples

			The initial terms of P, Q, R are:
1     5    11    20    36    60    94   140   199   272   360
   4     6     9    16    24    34    46    59    73    88
      2     3     7     8    10    12    13    14    15
		

References

  • M. Gardner, Weird Numbers from Titan, Isaac Asimov's Science Fiction Magazine, Vol. 4, No. 5, May 1980, pp. 42ff.

Crossrefs

Programs

  • Maple
    Hofstadter2 := proc (N) local h, dh, ddh, S, lbmex, i:
        h := 1, 5, 11: dh := 4, 6: ddh := 2:
        lbmex := 3: S := {h,dh,ddh}:
        for i from 4 to N do:
           while lbmex in S do: S := S minus {lbmex}: lbmex := lbmex + 1: od:
           ddh := ddh, lbmex:
           dh := dh, dh[-1] + lbmex:
           h := h, h[-1] + dh[-1]:
           S := S union {h[-1], dh[-1], ddh[-1]}:
           lbmex := lbmex + 1:
        od:
        if {h} intersect {dh} <> {} then: return NULL:
        elif {h} intersect {ddh} <> {} then: return NULL:
        elif {ddh} intersect {dh} <> {} then: return NULL:
        else: return [h]: fi:
    end proc: # Christopher Carl Heckman, May 12 2013
  • Mathematica
    Hofstadter2[N_] := Module[{P, Q, R, S, k, i}, P = {1, 5, 11}; Q = {4, 6}; R = {2}; k = 3; S = Join[P, Q, R]; For[i = 4, i <= N, i++, While[MemberQ[S, k], S = S~Complement~{k}; k++]; AppendTo[R, k]; AppendTo[Q, Q[[-1]] + k]; AppendTo[P, P[[-1]] + Q[[-1]]]; S = S~Union~{P[[-1]], Q[[-1]], R[[-1]]}; k++]; Which[P~Intersection~Q != {}, Return@Nothing, {P}~Intersection~R != {}, Return@Nothing, R~Intersection~Q != {}, Return@Nothing, True, Return@P]];
    Hofstadter2[36] (* Jean-François Alcover, Mar 05 2023, after Christopher Carl Heckman's Maple code *)

Extensions

Corrected and edited by Christopher Carl Heckman, May 12 2013

A225377 Construct sequences P,Q,R by the rules: Q = first differences of P, R = second differences of P, P starts with 1,5,11, Q starts with 4,6, R starts with 2; at each stage the smallest number not yet present in P,Q,R is appended to R; every number appears exactly once in the union of P,Q,R. Sequence gives Q.

Original entry on oeis.org

4, 6, 9, 16, 24, 34, 46, 59, 73, 88, 105, 123, 142, 163, 185, 208, 233, 259, 286, 314, 343, 373, 404, 436, 469, 504, 541, 579, 618, 658, 699, 741, 784, 828, 873, 920, 968, 1017, 1067, 1118, 1170
Offset: 1

Author

N. J. A. Sloane, May 12 2013, based on email from Christopher Carl Heckman, May 06 2013

Keywords

Comments

P can be extended for 10^6 terms, but it is not known if P,Q,R can be extended to infinity.
A probabilistic argument suggests that P, Q, R are infinite. - N. J. A. Sloane, May 19 2013

Examples

			The initial terms of P, Q, R are:
1     5    11    20    36    60    94   140   199   272   360
   4     6     9    16    24    34    46    59    73    88
      2     3     7     8    10    12    13    14    15
		

Crossrefs

Programs

Extensions

Corrected and edited by Christopher Carl Heckman, May 12 2013

A225378 Construct sequences P,Q,R by the rules: Q = first differences of P, R = second differences of P, P starts with 1,5,11, Q starts with 4,6, R starts with 2; at each stage the smallest number not yet present in P,Q,R is appended to R; every number appears exactly once in the union of P,Q,R. Sequence gives R.

Original entry on oeis.org

2, 3, 7, 8, 10, 12, 13, 14, 15, 17, 18, 19, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 61, 62, 63, 64
Offset: 1

Author

N. J. A. Sloane, May 12 2013, based on email from Christopher Carl Heckman, May 06 2013

Keywords

Comments

P can be extended for 10^6 terms, but it is not known if P,Q,R can be extended to infinity.
A probabilistic argument suggests that P, Q, R are infinite. - N. J. A. Sloane, May 19 2013

Examples

			The initial terms of P, Q, R are:
1     5    11    20    36    60    94   140   199   272   360
   4     6     9    16    24    34    46    59    73    88
      2     3     7     8    10    12    13    14    15
		

Crossrefs

Programs

Extensions

Corrected and edited by Christopher Carl Heckman, May 12 2013

A225850 Inverse of permutation in A167151.

Original entry on oeis.org

0, 1, 2, 3, 4, 6, 8, 5, 10, 12, 14, 16, 7, 18, 20, 22, 24, 26, 9, 28, 30, 32, 34, 36, 38, 40, 11, 42, 44, 46, 48, 50, 52, 54, 56, 13, 58, 60, 62, 64, 66, 68, 70, 72, 74, 15, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 17, 96, 98, 100, 102, 104, 106, 108, 110, 112
Offset: 0

Author

Reinhard Zumkeller, May 17 2013

Keywords

Comments

For n > 0: a(A005228(n)) = 2*n-1 and a(A030124(n)) = 2*n.
For n > 0: A232739(n) = a(A232739(n+1))/2. - Antti Karttunen, Dec 04 2013

Crossrefs

Inverse permutation: A167151.
Cf. also A005228, A030124, A232739, A232746, A232747, A232749, and also the permutation pair A232751/A232752.

Programs

  • Haskell
    import Data.List (elemIndex)
    import Data.Maybe (fromJust)
    a225850 = fromJust . (`elemIndex` a167151_list)
    
  • Mathematica
    nmax = 100; A5228 = {1};
    Module[{d = 2, k = 1}, Do[While[MemberQ[A5228, d], d++]; k += d; d++; AppendTo[A5228, k], {n, 1, nmax}]];
    a46[n_] := For[k = 1, True, k++, If[A5228[[k]] > n, Return[k - 1]]];
    a47[n_] := If[n == 1, 1, a46[n] (a46[n] - a46[n - 1])];
    a48[n_] := a48[n] = If[n == 1, 0, a48[n-1] + (1 - (a46[n] - a46[n-1]))];
    a49[n_] := If[n == 1, 0, a48[n] (a48[n] - a48[n - 1])];
    a[n_] := If[n < 3, n, 2 (a47[n] + a49[n]) - (a46[n] - a46[n - 1])];
    Table[a[n], {n, 0, nmax}] (* Jean-François Alcover, Dec 09 2021 *)
  • Scheme
    (define (A225850 n) (if (< n 3) n (- (* 2 (+ (A232747 n) (A232749 n))) (- (A232746 n) (A232746 (- n 1))))))
    ;; Antti Karttunen, Dec 04 2013

Formula

If n < 3, a(n) = n, otherwise a(n) = (2*(A232747(n)+A232749(n))) - (A232746(n)-A232746(n-1)). - Antti Karttunen, Dec 04 2013

A121229 Beginning with a(1) = 1 and a(2) = 2, a(n) is not equal to the product of two consecutive (distinct) earlier terms.

Original entry on oeis.org

1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78
Offset: 1

Author

Giovanni Teofilatto, Aug 21 2006

Keywords

Crossrefs

The complement is A286290, excluding the initial 1.

Programs

  • Maple
    A121229 := proc(n)
        option remember;
        local a,ispr,i;
        if n <=2 then
            n;
        else
            for a from procname(n-1)+1 do
                ispr := false ;
                for i from 1 to n-2 do
                    if procname(i)*procname(i+1) = a then
                        ispr := true ;
                        break;
                    end if;
                end do:
                if not ispr then
                    return a;
                end if;
            end do:
        end if;
    end proc: # R. J. Mathar, May 25 2017
  • Mathematica
    a[n_] := a[n] = Module[{k, ispr, i}, If[n <= 2, n, For[k = a[n - 1] + 1, True, k++, ispr = False; For[i = 1, i <= n - 2, i++, If[a[i]*a[i + 1] == k, ispr = True; Break[]]]; If[!ispr, Return[k]]]]];
    Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Sep 23 2022, after R. J. Mathar *)
  • Python
    from itertools import islice
    def agen(): # generator of terms
        disallowed, prevk, k = {1, 2}, 2, 3; yield from [1, 2]
        while True:
            while k in disallowed: k += 1
            yield k; disallowed.update([k, k*prevk]); prevk = k
    print(list(islice(agen(), 72))) # Michael S. Branicky, Sep 23 2022

A140778 a(n) is the smallest positive integer such that no number occurs twice in the union of the sequence and its absolute first differences.

Original entry on oeis.org

1, 3, 7, 12, 18, 8, 17, 28, 13, 27, 43, 19, 39, 60, 22, 45, 70, 26, 55, 85, 31, 63, 96, 34, 69, 105, 37, 77, 118, 42, 88, 135, 48, 97, 147, 52, 103, 156, 56, 113, 171, 59, 120, 184, 65, 131, 198, 71, 143, 216, 74, 149, 227, 79, 159, 240, 82, 165, 249, 86, 175, 265, 91, 183
Offset: 1

Author

Keywords

Comments

This sequence and its first differences include every positive integer (exactly once).

Examples

			For a(5), the sequence to that point is [1,3,7,12], with absolute differences [2,4,5]. The next number cannot be 6, because then 6 would be in both the sequence and the first differences. Since all values smaller than 6 are taken, the difference must be positive and at least 6. A difference of 6 works, a(5) = 18.
		

Programs

  • Maple
    b:= proc() false end:
    a:= proc(n) option remember; local k;
          if n=1 then b(1):= true; 1
        else for k while b(k) or (t-> b(t) or t=k)(abs(a(n-1)-k)) do od;
             b(k), b(abs(a(n-1)-k)):= true$2; k
          fi
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, May 14 2015
  • Mathematica
    a[n_] := a[n] = Module[{}, If [n == 1, b[1] = True; 1, For[k = 1, b[k] || Function[t, b[t] || t == k][Abs[a[n-1] - k]], k++]; {b[k], b[Abs[a[n-1] - k]]} = {True, True}; k]]; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Jan 22 2017, after Alois P. Heinz *)
  • PARI
    IsInList(v, k) = for(i=1,#v,if(v[i]==k,return(1)));return(0) IsInDiff(v, k) = for(i=2,#v,if(abs(v[i]-v[i-1])==k,return(1)));return(0) NextA140778(v)={ local(i,d); if(#v==0,return(1)); i=2; while(1, d=abs(i-v[ #v]); if(!(i==d || IsInList(v,i) || IsInDiff(v,i) || IsInList(v,d) || IsInDiff(v,d)), return(i)); i++) } v=[];for(i=1,100,v=concat(v,NextA140778(v)));v
    
  • PARI
    {u=0;a=1;for(n=1,99,u+=1<M. F. Hasler, May 13 2015

A232747 Inverse function to Hofstadter's A005228.

Original entry on oeis.org

1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0
Offset: 1

Author

Antti Karttunen, Nov 30 2013

Keywords

Comments

This is an inverse function to Hofstadter's A005228 in the sense that for all n, n = a(A005228(n)). a(n) = 0 when n is not in A005228, but instead in its complement A030124.
Note that a(n)*A232749(n) = 0 for all n.
Used to compute the permutation A232751.

Crossrefs

A030124 gives the positions of zeros.

Programs

  • Mathematica
    nmax = 100; A5228 = {1}; Module[{d = 2, k = 1}, Do[While[MemberQ[A5228, d], d++]; k += d; d++; AppendTo[A5228, k], {n, 1, nmax}]];
    a46[n_] := For[k = 1, True, k++, If[A5228[[k]] > n, Return[k - 1]]];
    a[n_] := If[n == 1, 1, a46[n] (a46[n] - a46[n - 1])];
    Array[a, nmax] (* Jean-François Alcover, Dec 09 2021 *)

Formula

a(1)=1, and for n>1, a(n) = A232746(n) * (A232746(n)-A232746(n-1)).
Previous Showing 11-20 of 37 results. Next