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

This page as a plain text file.
%I A383594 #22 Jul 09 2025 17:54:43
%S A383594 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,
%T A383594 21,41,2,23,2,24,47,2,26,51,77,104,132,161,191,2,33,65,98,132,167,2,
%U A383594 38,75,113,2,41,2,42,83,2,44,87,131,2,47,2,48,95,143,192,242
%N 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).
%C A383594 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).
%H A383594 Aaron Pieniozek, <a href="/A383594/b383594.txt">Table of n, a(n) for n = 0..199</a>
%e A383594 The sequence, and the k increments applied, begin
%e A383594   a(n) = 0, 1, 3, 2, 5, 2, 6, 11, 2, 8, 15, 23, ...
%e A383594   k    =   1  2     3     4  5      6  7   8
%p A383594 seq := proc(n)
%p A383594     local a, i, k;
%p A383594     a := [0];
%p A383594     k := 1;
%p A383594     for i from 1 to n-1 do
%p A383594         if isprime(a[-1]) and a[-1] <> 2 then
%p A383594             a := [op(a), 2];
%p A383594         else
%p A383594             a := [op(a), a[-1] + k];
%p A383594             k := k + 1;
%p A383594         end if;
%p A383594     end do;
%p A383594     return a;
%p A383594 end proc:
%t A383594 sequence[n_] := Module[{a = {0}, k = 1},
%t A383594   While[Length[a] < n,
%t A383594     If[PrimeQ[Last[a]] && Last[a] != 2,
%t A383594       AppendTo[a, 2],
%t A383594       AppendTo[a, Last[a] + k];
%t A383594       k++
%t A383594     ];
%t A383594   ];
%t A383594   a
%t A383594 ]
%K A383594 nonn
%O A383594 0,3
%A A383594 _Aaron Pieniozek_, May 01 2025