login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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. 1
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, 106, 132, 159, 187, 216, 246, 277, 15, 48, 82, 117, 153, 190, 228, 267, 307, 16, 58, 101, 17, 18, 64, 111, 159, 208, 258, 309, 361, 414, 468, 523, 19, 20, 78, 137, 22, 83, 24, 87, 151, 25, 91 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
LINKS
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
Sequence in context: A060984 A226947 A272615 * A238962 A238975 A098348
KEYWORD
nonn,easy
AUTHOR
John Tyler Rascoe, Jul 28 2022
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 29 06:09 EDT 2024. Contains 375510 sequences. (Running on oeis4.)