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

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 *)

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

A330772 a(n) = 1 for n<1; for n >= 0, a(n+1) = 2*a(n-a(n)).

Original entry on oeis.org

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

Views

Author

Rok Cestnik, Dec 30 2019

Keywords

Comments

From the current term count back the same number of terms and double it to obtain the next term. Because a(n) can exceed n, negative indexes are also occasionally referenced.

Examples

			a(1) = 2*a(0-a(0)) = 2*a(-1) = 2.
a(2) = 2*a(1-a(1)) = 2*a(-1) = 2.
a(3) = 2*a(2-a(2)) = 2*a(0) = 2.
a(4) = 2*a(3-a(3)) = 2*a(1) = 4.
		

Crossrefs

Programs

  • Python
    a = [2]
    for n in range(1000):
        if(a[n] > n):
            a.append(2)
        else:
            a.append(2*a[n-a[n]])

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;
    }

A364197 a(n+1) = a(|n-a(n)^2|) + 1, a(0) = 0.

Original entry on oeis.org

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

Views

Author

Rok Cestnik, Jul 13 2023

Keywords

Examples

			a(1) = a(|0-a(0)^2|)+1 = a(|0-0|)+1 = a(0)+1 = 1.
a(2) = a(|1-a(1)^2|)+1 = a(|1-1|)+1 = a(0)+1 = 1.
a(3) = a(|2-a(2)^2|)+1 = a(|2-1|)+1 = a(1)+1 = 2.
a(4) = a(|3-a(3)^2|)+1 = a(|3-4|)+1 = a(1)+1 = 2.
a(5) = a(|4-a(4)^2|)+1 = a(|4-4|)+1 = a(0)+1 = 1.
		

Crossrefs

Cf. A364198 (indices of record highs).

Programs

  • Mathematica
    a[0] = 0; a[n_] := a[n] = a[Abs[n - 1 - a[n - 1]^2]] + 1; Array[a, 100, 0] (* Amiram Eldar, Jul 13 2023 *)
  • Python
    a = [0]; [a.append(a[abs(n-a[n]**2)]+1) for n in range(100)]

Formula

a(n) ~ (3n)^(1/3) (conjectured).

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;
    }

A330631 a(n+1) = a(n-a(n))+1 if a(n) > a(n-1), otherwise a(n+1) = 2*a(n); a(1) = a(2) = 1.

Original entry on oeis.org

1, 1, 2, 2, 4, 2, 4, 3, 6, 3, 6, 5, 10, 3, 6, 7, 7, 14, 3, 6, 4, 8, 4, 8, 8, 16, 4, 8, 7, 14, 8, 16, 8, 16, 15, 30, 3, 6, 17, 9, 18, 5, 10, 9, 18, 5, 10, 4, 8, 19, 9, 18, 17, 34, 7, 14, 6, 12, 6, 12, 5, 10, 19, 10, 20, 19, 38, 8, 16, 18, 19, 19, 38, 16, 32
Offset: 1

Views

Author

Rok Cestnik, Dec 21 2019

Keywords

Comments

a(n) < n (with exception a(1) = 1). Proof: Suppose a(s) = s+x, x >= 0, is the first occurrence of a(n) >= n. From here we branch into two possibilities: Possibility #1: a(s-2) < a(s-1), from which it follows that a(s) = a(s-1-a(s-1))+1 and therefore a(s-1-a(s-1)) = s-1+x is an earlier example of a(n) >= n. Possibility #2: a(s-2) >= a(s-1) and the terms can be expressed as a(s-1) = (s+x)/2 and a(s-2) = (s+x)/2+y with y >= 0. From this it follows that a(s-2-((s+x)/2+y))+1 = (s+x)/2, which when simplified reveals that a((s+x)/2-2-x-y) = (s+x)/2-1 is an earlier example of a(n) >= n. Both possibilities lead to a contradiction of the first statement, therefore we conclude that there is no occurrence of a(n) >= n (with exception a(1) = 1).
Some numbers never seem to appear in the sequence; the smallest of these are 328, 329, 331, 332, 333, 445, 667, 668, 669, ...

Examples

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

Crossrefs

See A281130 for a similar sequence.

Programs

  • Mathematica
    Nest[Append[#, If[Less @@ Take[#, -2], #[[Length@ # - #[[-1]] ]] + 1, 2 #[[-1]] ]] &, {1, 1}, 73] (* Michael De Vlieger, Dec 23 2019 *)
  • Python
    a = [1,1]
    for n in range(1, 1000):
        if(a[n] > a[n-1]):
            a.append(a[n-a[n]]+1)
        else:
            a.append(2*a[n])
Showing 1-7 of 7 results.