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

A281130 a(n+1) = a(n-a(n)) if a(n-1) < a(n), otherwise a(n+1) = 2*a(n); a(1) = a(2) = 1.

Original entry on oeis.org

1, 1, 2, 1, 2, 2, 4, 2, 4, 2, 4, 4, 8, 2, 4, 4, 8, 4, 8, 4, 8, 8, 16, 4, 8, 8, 16, 4, 8, 8, 16, 4, 8, 8, 16, 8, 16, 8, 16, 16, 32, 4, 8, 16, 4, 8, 8, 16, 4, 8, 4, 8, 16, 16, 32, 16, 32, 8, 16, 8, 16, 4, 8, 32, 4, 8, 8, 16, 8, 16, 16, 32, 16, 32, 4, 8, 16, 16, 32, 8
Offset: 1

Views

Author

Rok Cestnik, Jan 15 2017

Keywords

Comments

The sequence is well defined, namely a(n) < n (with the exception of a(1)). Proof: Suppose a(s) = s+m, with m >= 0, is the first occurrence of a(n) >= n. It follows that a(s-1) = a(s-2) = (s+m)/2 and from there it follows that a(s-2-(s+m)/2) = (s+m)/2, but s-2-(s+m)/2 < (s+m)/2 which is a contradiction to the first statement. - Rok Cestnik, Aug 29 2017
From Robert G. Wilson v, Jan 16 2017: (Start)
a(n) = 2^k, k >= 0.
a(n)=1 for n: 1, 2, 4;
a(n)=2 for n: 3, 5, 6, 8, 10, 14;
a(n)=4 for n: 7, 9, 11, 12, 15, 16, 18, 20, 24, 28, 32, 42, 45, 49, 51, 62, 65, 75, 82, 84, 101, 108, 110, 118, 127, 175, 240;
First occurrence of 2^k (A281131): 1, 3, 7, 13, 23, 41, 98, 223, 437, 699, 1213, 2624, 4674, 11163, 21300, 40858, 73977, etc.;
Last occurrence of 2^k: 4, 14, 240, 1314, 10565, 35893, 62417, 638149, 2030926, etc.;
Number of occurrences of 2^k: 3, 6, 27, 77, 167, 330, 706, 1756, 3811, etc.
(End)

Examples

			a(3) = 2*a(2) = 2 because a(1) !< a(2).
a(4) = a(3-a(3)) = 1 because a(2) < a(3).
		

Crossrefs

Programs

  • C
    #include
    #include
    int main(void){
       int N = 1000;
       int *a = (int*)malloc((N+1)*sizeof(int));
       printf("1 1\n2 1\n");
       a[1] = 1;
       a[2] = 1;
       for(int i = 2; i < N; ++i){
          if(a[i-1] < a[i]) a[i+1] = a[i-a[i]];
          else a[i+1] = 2*a[i];
          printf("%d %d\n", i+1, a[i+1]);
       }
       return 0;
    }
  • Mathematica
    a[n_] := a[n] = If[a[n -2] < a[n -1], a[n -1 -a[n -1]], 2 a[n -1]]; a[1] = a[2] = 1; Array[a, 100]

A291598 a(n) = log_2(A281130(n)).

Original entry on oeis.org

0, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 3, 4, 4, 5, 2, 3, 4, 2, 3, 3, 4, 2, 3, 2, 3, 4, 4, 5, 4, 5, 3, 4, 3, 4, 2, 3, 5, 2, 3, 3, 4, 3, 4, 4, 5, 4, 5, 2, 3, 4, 4, 5, 3, 4, 2, 3, 2, 3, 4, 4, 5, 4, 5, 3, 4, 3, 4, 4, 5, 5, 6
Offset: 1

Views

Author

Rok Cestnik, Aug 27 2017

Keywords

Crossrefs

Programs

  • C
    #include
    #include
    #include
    int main(void){
       int N = 100;
       int *a = (int*)malloc((N+1)*sizeof(int));
       printf("1 0\n2 0\n");
       a[1] = 0;
       a[2] = 0;
       for(int i = 2; i < N; ++i){
          if(a[i-1] < a[i]) a[i+1] = a[i-(int)(pow(2,a[i]))];
          else a[i+1] = a[i]+1;
          printf("%d %d\n", i+1, a[i+1]);
       }
       return 0;
    }
  • Mathematica
    a[n_] := a[n] = If[a[n - 2] < a[n - 1], a[n - 1 - a[n - 1]], 2 a[n - 1]]; a[1] = a[2] = 1; Array[Log2@ a@ # &, 105] (* Michael De Vlieger, Aug 29 2017 *)
Showing 1-2 of 2 results.