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.

A346035 a(1) = 1; if a(n) is not divisible by 3, a(n+1) = 4*a(n) + 1, otherwise a(n+1) = a(n)/3.

Original entry on oeis.org

1, 5, 21, 7, 29, 117, 39, 13, 53, 213, 71, 285, 95, 381, 127, 509, 2037, 679, 2717, 10869, 3623, 14493, 4831, 19325, 77301, 25767, 8589, 2863, 11453, 45813, 15271, 61085, 244341, 81447, 27149, 108597, 36199, 144797, 579189, 193063, 772253, 3089013, 1029671, 4118685
Offset: 1

Views

Author

Tristan Young, Jul 02 2021

Keywords

Crossrefs

Programs

  • Mathematica
    a[1] = 1; a[n_] := a[n] = If[Divisible[a[n-1],3], a[n-1]/3, 4*a[n-1]+1]; Array[a, 50] (* Amiram Eldar, Jul 12 2021 *)
  • PARI
    a(n) = if (n==1, 1, my(x=a(n-1)); if (x % 3, 4*x+1, x/3)); \\ Michel Marcus, Aug 12 2021
  • Processing
    // generates all the numbers in the sequence before it first surpasses 1 billion
    int n;
    void setup() {
      n = 1;
      noLoop();
    }
    void draw() {
      print(n + ",");
      while (true) {
        if (n % 3 == 0) {
          n /= 3;
        } else {
          n *= 4; n++;
        }
        print(n);
        if (n == 1 || n >= 600000000) {
          break;
        } else {
          print(", ");
        }
      }
    }