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.

A356188 a(1)=1; for n > 1, if a(n-1) is prime then a(n) = the smallest number not yet in the sequence. Otherwise a(n) = a(n-1) + n - 1.

This page as a plain text file.
%I A356188 #19 Sep 28 2022 08:13:21
%S A356188 1,2,3,4,8,13,5,6,14,23,7,9,21,34,48,63,79,10,28,47,11,12,34,57,81,
%T A356188 106,132,159,187,216,246,277,15,48,82,117,153,190,228,267,307,16,58,
%U A356188 101,17,18,64,111,159,208,258,309,361,414,468,523,19,20,78,137,22,83,24,87,151,25,91
%N A356188 a(1)=1; for n > 1, if a(n-1) is prime then a(n) = the smallest number not yet in the sequence. Otherwise a(n) = a(n-1) + n - 1.
%e A356188 a(8) = 6 because a(7) is prime and 6 is the smallest number that has not appeared in the sequence thus far.
%e A356188 a(9) = 6 + 9 - 1 = 14 because a(8) is not prime.
%t A356188 f[s_] := Module[{k=1, t}, t = If[!PrimeQ[s[[-1]]], s[[-1]] + Length[s], While[!FreeQ[s, k], k++]; k]; Join[s, {t}]]; Nest[f, {1}, 66] (* _Amiram Eldar_, Sep 28 2022 *)
%o A356188 (Python)
%o A356188 from sympy import isprime
%o A356188 from itertools import count, filterfalse
%o A356188 A356188 = A = [1]
%o A356188 for n in range(1,100):
%o A356188       if isprime(A[-1]):
%o A356188             y = next(filterfalse(set(A).__contains__, count(1)))
%o A356188       else:
%o A356188             y = A[-1] + n
%o A356188       A.append(y)
%Y A356188 Cf. A000040, A060735, A073659, A331603.
%K A356188 nonn,easy
%O A356188 1,2
%A A356188 _John Tyler Rascoe_, Jul 28 2022