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.

A383594 a(0) = 0 and thereafter a(n) = 2 if a(n-1) is an odd prime, otherwise a(n) = a(n-1) + k where k = n - P(n) and P(n) is the number of odd primes among terms a(0),...,a(n-1).

Original entry on oeis.org

0, 1, 3, 2, 5, 2, 6, 11, 2, 8, 15, 23, 2, 11, 2, 12, 23, 2, 14, 27, 41, 2, 17, 2, 18, 35, 53, 2, 21, 41, 2, 23, 2, 24, 47, 2, 26, 51, 77, 104, 132, 161, 191, 2, 33, 65, 98, 132, 167, 2, 38, 75, 113, 2, 41, 2, 42, 83, 2, 44, 87, 131, 2, 47, 2, 48, 95, 143, 192, 242
Offset: 0

Views

Author

Aaron Pieniozek, May 01 2025

Keywords

Comments

The number of terms between consecutive 2's is never 4*d, since the sum of 4*d consecutive values of k is always even and consequently a(n+4*d) is even (not a prime).

Examples

			The sequence, and the k increments applied, begin
  a(n) = 0, 1, 3, 2, 5, 2, 6, 11, 2, 8, 15, 23, ...
  k    =   1  2     3     4  5      6  7   8
		

Programs

  • Maple
    seq := proc(n)
        local a, i, k;
        a := [0];
        k := 1;
        for i from 1 to n-1 do
            if isprime(a[-1]) and a[-1] <> 2 then
                a := [op(a), 2];
            else
                a := [op(a), a[-1] + k];
                k := k + 1;
            end if;
        end do;
        return a;
    end proc:
  • Mathematica
    sequence[n_] := Module[{a = {0}, k = 1},
      While[Length[a] < n,
        If[PrimeQ[Last[a]] && Last[a] != 2,
          AppendTo[a, 2],
          AppendTo[a, Last[a] + k];
          k++
        ];
      ];
      a
    ]