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

A185256 Stanley Sequence S(0,3).

Original entry on oeis.org

0, 3, 4, 7, 9, 12, 13, 16, 27, 30, 31, 34, 36, 39, 40, 43, 81, 84, 85, 88, 90, 93, 94, 97, 108, 111, 112, 115, 117, 120, 121, 124, 243, 246, 247, 250, 252, 255, 256, 259, 270, 273, 274, 277, 279, 282, 283, 286, 324, 327, 328, 331, 333, 336, 337, 340, 351, 354, 355, 358, 360, 363
Offset: 1

Views

Author

N. J. A. Sloane, Mar 19 2011

Keywords

Comments

Given a finite increasing sequence V = [v_1, ..., v_k] containing no 3-term arithmetic progression, the Stanley Sequence S(V) is obtained by repeatedly appending the smallest term that is greater than the previous term and such that the new sequence also contains no 3-term arithmetic progression.

Examples

			After [0, 3, 4, 7, 9] the next term cannot be 10 or we would have the 3-term A.P. 4,7,10; it cannot be 11 because of 7,9,11; but 12 is OK.
		

References

  • R. K. Guy, Unsolved Problems in Number Theory, E10.

Crossrefs

For other examples of Stanley Sequences see A005487, A005836, A187843, A188052, A188053, A188054, A188055, A188056, A188057.
See also A004793, A033160, A033163.

Programs

  • Maple
    # Stanley Sequences, Discrete Math. vol. 311 (2011), see p. 560
    ss:=proc(s1,M) local n,chvec,swi,p,s2,i,j,t1,mmm; t1:=nops(s1); mmm:=1000;
    s2:=Array(1..t1+M,s1); chvec:=Array(0..mmm);
    for i from 1 to t1 do chvec[s2[i]]:=1; od;
    # Get n-th term:
    for n from t1+1 to t1+M do # do 1
    # Try i as next term:
    for i from s2[n-1]+1 to mmm do # do 2
    swi:=-1;
    # Test against j-th term:
    for j from 1 to n-2 do # do 3
    p:=s2[n-j];
    if 2*p-i < 0 then break; fi;
    if chvec[2*p-i] = 1 then swi:=1; break; fi;
    od; # od 3
    if swi=-1 then s2[n]:=i; chvec[i]:=1; break; fi;
    od; # od 2
    if swi=1 then ERROR("Error, no solution at n = ",n); fi;
    od; # od 1;
    [seq(s2[i],i=1..t1+M)];
    end;
    ss([0,3],80);
  • Mathematica
    ss[s1_, M_] := Module[{n, chvec, swi, p, s2, i, j, t1, mmm}, t1 = Length[s1]; mmm = 1000; s2 = Table[s1, {t1 + M}] // Flatten; chvec = Array[0&, mmm];
    For[i = 1, i <= t1, i++, chvec[[s2[[i]] ]] = 1];
    (* get n-th term *)
    For[n = t1+1, n <= t1 + M, n++,
    (* try i as next term *)
    For[i = s2[[n-1]] + 1, i <= mmm, i++, swi = -1;
    (* test against j-th term *)
    For[j = 1, j <= n-2, j++, p = s2[[n - j]]; If[2*p - i < 0, Break[] ];
    If[chvec[[2*p - i]] == 1, swi = 1; Break[] ] ];
    If[swi == -1, s2[[n]] = i; chvec[[i]] = 1; Break[] ] ];
    If[swi == 1, Print["Error, no solution at n = ", n] ] ];
    Table[s2[[i]], {i, 1, t1 + M}] ];
    ss[{0, 3}, 80] (* Jean-François Alcover, Sep 10 2013, translated from Maple *)
  • PARI
    A185256(n,show=1,L=3,v=[0,3], D=v->v[2..-1]-v[1..-2])={while(#v1||next(2), 2); break)); if(type(show)=="t_VEC", v, v[n])} \\ 2nd (optional) arg: zero = silent, nonzero = verbose, vector (e.g. [] or [1]) = get the whole list [a(1..n)] as return value, else just a(n). - M. F. Hasler, Jan 18 2016

A004793 a(1)=1, a(2)=3; a(n) is least k such that no three terms of a(1), a(2), ..., a(n-1), k form an arithmetic progression.

Original entry on oeis.org

1, 3, 4, 6, 10, 12, 13, 15, 28, 30, 31, 33, 37, 39, 40, 42, 82, 84, 85, 87, 91, 93, 94, 96, 109, 111, 112, 114, 118, 120, 121, 123, 244, 246, 247, 249, 253, 255, 256, 258, 271, 273, 274, 276, 280, 282, 283, 285, 325, 327, 328, 330, 334, 336, 337, 339, 352, 354
Offset: 1

Views

Author

Keywords

Crossrefs

Equals A186776(n)+1, A033160(n)-1, A033163(n)-2.
Row 1 of array in A093682.

Programs

  • Maple
    a:= proc(n) local m, r, b; m, r, b:= n-1, 2-irem(n, 2), 1;
          while m>0 do r:= r+b*irem(m, 2, 'm'); b:= b*3 od; r
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Nov 02 2021
  • Mathematica
    Select[Range[1000], MatchQ[IntegerDigits[#-1, 3], {(0|1)..., 0|2}]&] (* Jean-François Alcover, Jan 13 2019, after Tanya Khovanova in A186776 *)
  • PARI
    v[1]=1; v[2]=3; for(n=3,1000,f=2; m=v[n-1]+1; while(1, forstep(k=n-1,1,-1,if(v[k]<(m+1)/2,f=1; break); for(l=1,k-1,if(m-v[k]==v[k]-v[l],f=0; break)); if(f<2,break)); if(!f,m=m+1;f=2); if(f==1,break)); v[n]=m) \\ Ralf Stephan
    
  • PARI
    a(n)=if(n<1,1,if(n%2==0,3*a(n/2)-2-3*((n/2)%2),3*a((n-1)/2)-3*(((n-1)/2)%2))) \\ Ralf Stephan

Formula

a(n) = (3-n)/2 + 2*floor(n/2) + Sum_{k=1..n-1} 3^A007814(k)/2 = A003278(n) + [n is even], proved by Lawrence Sze, following a conjecture by Ralf Stephan.
a(n) = b(n-1), with b(0)=1, b(2n) = 3b(n) - 2 - 3[n odd], b(2n+1) = 3b(n)-3[n odd].

Extensions

Rechecked by David W. Wilson, Jun 04 2002

A186776 Stanley Sequence S(0,2).

Original entry on oeis.org

0, 2, 3, 5, 9, 11, 12, 14, 27, 29, 30, 32, 36, 38, 39, 41, 81, 83, 84, 86, 90, 92, 93, 95, 108, 110, 111, 113, 117, 119, 120, 122, 243, 245, 246, 248, 252, 254, 255, 257, 270, 272, 273, 275, 279, 281, 282, 284, 324, 326, 327, 329, 333, 335, 336, 338, 351, 353, 354, 356, 360, 362, 363, 365, 729, 731, 732, 734, 738, 740
Offset: 1

Views

Author

N. J. A. Sloane, Mar 19 2011

Keywords

Comments

See A185256.
In ternary these numbers have 0's and 1's everywhere, except the last digit is either 0 or 2. [Tanya Khovanova, Nov 16 2013]
a(n) = A005836(n) + A000035(n). [Tanya Khovanova, Nov 16 2013]

Crossrefs

Programs

Formula

Equals A004793(n)-1, also A033160(n)-2, also A033163(n)-3. Note that A004793 has a recurrence.

A033160 Begins with (2, 4); avoids 3-term arithmetic progressions.

Original entry on oeis.org

2, 4, 5, 7, 11, 13, 14, 16, 29, 31, 32, 34, 38, 40, 41, 43, 83, 85, 86, 88, 92, 94, 95, 97, 110, 112, 113, 115, 119, 121, 122, 124, 245, 247, 248, 250, 254, 256, 257, 259, 272, 274, 275, 277, 281, 283, 284, 286, 326, 328, 329, 331, 335, 337, 338, 340, 353, 355, 356, 358, 362
Offset: 1

Views

Author

Keywords

Crossrefs

a(n) = A186776(n)+2 = A004793(n)+1 = A033163(n)-1. Cf. A185256.

Programs

A267650 Stanley sequence S_4(0,3): lexicographic first increasing sequence with a(0) = 0, a(1) = 3 and no 4 terms in arithmetic progression.

Original entry on oeis.org

0, 3, 4, 5, 7, 8, 10, 11, 16, 17, 18, 20, 21, 27, 28, 29, 31, 32, 34, 35, 36, 53, 55, 56, 57, 60, 61, 62, 64, 67, 69, 75, 87, 91, 100, 101, 103, 104, 105, 108, 109, 110, 114, 116, 120, 125, 127, 128, 129, 132, 134, 135, 164, 168, 173, 174, 175, 177, 181, 182, 184, 188, 190
Offset: 0

Views

Author

M. F. Hasler, Jan 18 2016

Keywords

Comments

See A185256 for S(0,3) = S_3(0,3) and A266728 for S_5(0,3).

Crossrefs

For other examples of Stanley Sequences see A005487, A005836, A187843, A188052, A188053, A188054, A188055, A188056, A188057, A266727, A266728.
See also A004793, A033160, A033163.

Programs

  • PARI
    a(n,show=1,L=4,v=[0,3], D=v->v[2..-1]-v[1..-2])={while(#v<=n, show&&print1(v[#v]", "); v=concat(v, v[#v]); while(v[#v]++, forvec(i=vector(L, j, [if(j1||next(2), 2); break)); if(type(show)=="t_VEC", v, v[n+1])} \\ 2nd (optional) arg: zero = silent, nonzero = verbose, vector (e.g. [] or [1]) = get the whole list [a(1..n)] as return value, else just a(n). - M. F. Hasler, Jan 18 2016
Showing 1-5 of 5 results.