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.

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]

A281131 First appearance of 2^n in A281130.

Original entry on oeis.org

1, 3, 7, 13, 23, 41, 98, 223, 437, 699, 1213, 2624, 4674, 11163, 21300, 40858, 73977, 148591, 297394, 567076, 1100738, 2243474, 4340628, 8726122, 17397270, 34701556, 68372147, 136254352, 271069771, 546613630, 1088921640, 2163138108, 4334318825
Offset: 0

Views

Author

Rok Cestnik, Jan 15 2017

Keywords

Comments

Conjecture: a(n) ~ 2^n.

Examples

			a(1) = 3 because A281130(3) = 2^1 and A281130(i) != 2^1 for i < 3.
a(2) = 7 because A281130(7) = 2^2 and A281130(i) != 2^2 for i < 7.
		

Crossrefs

Programs

  • C
    #include
    #include
    int main(void){
       int N = 1000000000;
       int *a = (int*)malloc((N+1)*sizeof(int));
       int max = 1;
       int maxindex = 1;
       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];
          if(a[i+1] > max){
             max = a[i+1];
             printf("%d %d\n", maxindex, i+1);
             maxindex++;
          }
       }
       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; Function[w, Function[e, First /@ Lookup[w, 2^e]]@ Range[0, Log2@ Max@ Keys@ w]]@ PositionIndex@ Array[a, 10^7] (* Michael De Vlieger, Jan 21 2017, Version 10. *)

Extensions

a(31)-a(32) from Rok Cestnik, Aug 27 2017

A318281 a(n+1) = a(n-a(n)) if a(n-1) != a(n), otherwise a(n+1) = a(n) + 3; a(1) = a(2) = a(3) = a(4) = 1.

Original entry on oeis.org

1, 1, 1, 1, 4, 1, 4, 1, 4, 4, 7, 1, 7, 1, 7, 1, 7, 4, 1, 4, 1, 4, 4, 7, 7, 10, 1, 10, 4, 7, 4, 1, 4, 4, 7, 10, 10, 13, 7, 1, 7, 4, 13, 7, 10, 7, 7, 10, 13, 10, 1, 10, 4, 13, 7, 10, 7, 10, 10, 13, 7, 13, 13, 16, 10, 7, 10
Offset: 1

Views

Author

Rok Cestnik, Aug 23 2018

Keywords

Comments

Sequences with an analogous condition a(n+1) = a(n) + s for s != 3 tend towards repetitive patterns:
for even values of s this is obvious, e.g.:
s = 2: 1,1,1,3,1,3,1,3,... (1,3 repeats)
s = 4: 1,1,1,1,1,5,1,5,1,5,1,5,... (1,5 repeats)
for odd values of s it has been checked up to s <= 19:
s = 1: 1,1,2,1,2,2,3,1,3,2,1,2,2,3,1,3,... (2,1,2,2,3,1,3 repeats)
s = 5: settles to a repetitive pattern of 192 terms
s = 7: settles to a repetitive pattern of 25 terms
s = 9: settles to a repetitive pattern of 31 terms
s = 11: settles to a repetitive pattern of 37 terms
s = 13: settles to a repetitive pattern of 43 terms
s = 15: settles to a repetitive pattern of 49 terms
s = 17: settles to a repetitive pattern of 55 terms
s = 19: settles to a repetitive pattern of 61 terms
It appears that for further values of s such sequences settle to a repetitive pattern of 4 + 3*s terms.

Examples

			a(5) = a(4) + 3 = 4, because a(3) == a(4).
a(6) = a(5-a(5)) = a(1) = 1, because a(4) != a(5).
		

Crossrefs

See A318282 for (a(n)-1)/3.

Programs

  • C
    #include
    #include
    #include
    int main(void){
      int N = 100; //number of terms
      int *a = (int*)malloc((N+1)*sizeof(int));
      printf("1 1\n2 1\n3 1\n4 1\n");
      a[1] = 1;
      a[2] = 1;
      a[3] = 1;
      a[4] = 1;
      for(int i = 4; i < N; ++i){
        if(a[i-1] != a[i]) a[i+1] = a[i-a[i]];
        else a[i+1] = a[i]+3;
        printf("%d %d\n", i+1, a[i+1]);
      }
      free(a);
      return 0;
    }

A318282 a(n) = (A318281(n) - 1)/3.

Original entry on oeis.org

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

Views

Author

Rok Cestnik, Aug 23 2018

Keywords

Crossrefs

Programs

  • C
    #include
    #include
    #include
    int main(void){
      int N = 100; //number of terms
      int *a = (int*)malloc((N+1)*sizeof(int));
      printf("1 0\n2 0\n3 0\n4 0\n");
      a[1] = 0;
      a[2] = 0;
      a[3] = 0;
      a[4] = 0;
      for(int i = 4; i < N; ++i){
        if(a[i-1] != a[i]) a[i+1] = a[i-(3*a[i]+1)];
        else a[i+1] = a[i]+1;
        printf("%d %d\n", i+1, a[i+1]);
      }
      free(a);
      return 0;
    }
Showing 1-4 of 4 results.