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

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

Views

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.
		

Crossrefs

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

A257944 Lexicographically earliest sequence of positive integers such that the terms and their absolute first differences are all distinct and no term is the sum of two distinct terms.

Original entry on oeis.org

1, 3, 7, 12, 18, 26, 16, 31, 20, 37, 50, 22, 41, 64, 35, 56, 83, 39, 69, 45, 54, 79, 111, 58, 92, 130, 60, 96, 136, 73, 115, 163, 75, 121, 168, 77, 134, 193, 98, 149, 182, 102, 157, 206, 117, 178, 244, 138, 210, 277, 140, 214, 282, 153, 229, 307, 155, 220, 263
Offset: 1

Views

Author

Eric Angelini and Alois P. Heinz, May 13 2015

Keywords

Comments

The sequence of absolute first differences begins: 2, 4, 5, 6, 8, 10, 15, 11, 17, 13, 28, 19, 23, 29, 21, 27, 44, 30, 24, 9, 25, 32, 53, ... .

Crossrefs

Programs

  • Maple
    s:= proc() false end: b:= proc() false end:
    a:= proc(n) option remember; local i, k, ok;
          if n=1 then b(1):= true; 1
        else for k do if b(k) or s(k) or (t-> b(t) or t=k)(
               abs(a(n-1)-k)) then next fi; ok:=true;
               for i to n-1 while ok do if b(k+a(i))
                 then ok:=false fi od; if ok then break fi
             od;
             for i to n-1 do s(a(i)+k):= true od;
             b(k), b(abs(a(n-1)-k)):= true$2; k
          fi
        end:
    seq(a(n), n=1..101);
  • Mathematica
    s[] = False; b[] = False;
    a[n_] := a[n] = Module[{i, k, ok}, If[n == 1, b[1] = True; 1,
         For[k = 1, True, k++, If[b[k] || s[k] || Function[t, b[t] ||
         t == k][Abs[a[n-1] - k]], Continue[]]; ok = True;
                 For[i = 1, i <= n-1 && ok, i++, If[b[k + a[i]],
                 ok = False]]; If[ok, Break[]]];
              For[i = 1, i <= n-1, i++, s[a[i] + k] = True];
              {b[k], b[Abs[a[n-1] - k]]} = {True, True}; k]];
    Table[a[n], {n, 1, 101}] (* Jean-François Alcover, Jul 16 2021, after Alois P. Heinz *)

A258136 Lexicographically earliest sequence of odd positive integers such that the terms and their absolute first differences are all distinct.

Original entry on oeis.org

1, 3, 7, 13, 5, 15, 27, 9, 23, 39, 11, 31, 53, 17, 41, 67, 19, 49, 81, 21, 55, 93, 25, 65, 107, 29, 73, 119, 33, 83, 135, 35, 89, 145, 37, 95, 157, 43, 109, 45, 115, 187, 47, 121, 197, 51, 131, 213, 57, 141, 229, 59, 149, 241, 61, 155, 251, 63, 161, 263, 69
Offset: 1

Views

Author

Eric Angelini and Alois P. Heinz, May 21 2015

Keywords

Crossrefs

Cf. A081145, A258137 (absolute first differences), A257941, A257944.

Programs

  • Maple
    b:= proc() false end:
    a:= proc(n) option remember; local k;
          if n=1 then b(1):= true; 1
        else a(n-1); for k while b(k) or
             b(abs(a(n-1)-k)) by 2 do od;
             b(k), b(abs(a(n-1)-k)):= true$2; k
          fi
        end:
    seq(a(n), n=1..101);
  • Mathematica
    b[_] = False;
    a[n_] := a[n] = Module[{k},
         If[n == 1, b[1] = True; 1,
         a[n-1]; For[k = 1, b[k] ||
         b[Abs[a[n-1] - k]], k += 2];
         {b[k], b[Abs[a[n-1] - k]]} = {True, True}; k]];
    Table[a[n], {n, 1, 101}] (* Jean-François Alcover, Aug 01 2021, after Alois P. Heinz *)

Formula

a(n) = 2*A081145(n)-1.

A258137 Absolute first differences of the lexicographically earliest sequence of odd positive integers such that the terms and their absolute first differences are all distinct.

Original entry on oeis.org

2, 4, 6, 8, 10, 12, 18, 14, 16, 28, 20, 22, 36, 24, 26, 48, 30, 32, 60, 34, 38, 68, 40, 42, 78, 44, 46, 86, 50, 52, 100, 54, 56, 108, 58, 62, 114, 66, 64, 70, 72, 140, 74, 76, 146, 80, 82, 156, 84, 88, 170, 90, 92, 180, 94, 96, 188, 98, 102, 194, 104, 106, 208
Offset: 1

Views

Author

Eric Angelini and Alois P. Heinz, May 21 2015

Keywords

Comments

All terms are even.

Crossrefs

Absolute first differences of A258136.

Programs

  • Maple
    b:= proc() false end:
    g:= proc(n) option remember; local k;
          if n=1 then b(1):= true; 1
        else g(n-1); for k while b(k) or
             b(abs(g(n-1)-k)) by 2 do od;
             b(k), b(abs(g(n-1)-k)):= true$2; k
          fi
        end:
    a:= n-> abs(g(n+1)-g(n)):
    seq(a(n), n=1..101);
  • Mathematica
    b[_] = False;
    g[n_] := g[n] = Module[{k},
         If[n == 1, b[1] = True; 1,
         g[n-1]; For[k = 1, b[k] ||
         b[Abs[g[n-1] - k]], k += 2];
         {b[k], b[Abs[g[n-1] - k]]} = {True, True}; k]];
    a[n_] := Abs[g[n+1] - g[n]];
    Table[a[n], {n, 1, 101}] (* Jean-François Alcover, Aug 01 2021, after Alois P. Heinz *)

Formula

a(n) = abs(A258136(n+1)-A258136(n)).
a(n) = 2*abs(A099004(n)).
Showing 1-4 of 4 results.