OFFSET
1,2
EXAMPLE
a(8) = 6 because a(7) is prime and 6 is the smallest number that has not appeared in the sequence thus far.
a(9) = 6 + 9 - 1 = 14 because a(8) is not prime.
MATHEMATICA
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 *)
PROG
(Python)
from sympy import isprime
from itertools import count, filterfalse
A356188 = A = [1]
for n in range(1, 100):
if isprime(A[-1]):
y = next(filterfalse(set(A).__contains__, count(1)))
else:
y = A[-1] + n
A.append(y)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
John Tyler Rascoe, Jul 28 2022
STATUS
approved