A376198 a(1) = 1, a(2) = 2. Thereafter, let smc and smp denote the smallest missing composite and smallest missing prime. If a(n) is composite, then if a(n) = 2*smp then a(n+1) = smp, otherwise a(n+1) = smc; if a(n) is a prime, then if smp < smc, a(n+1) = smp, otherwise a(n+1) = smc.
1, 2, 3, 4, 6, 8, 9, 10, 5, 7, 11, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 13, 17, 19, 23, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 29, 31, 37, 41, 43, 47, 53, 59, 60, 62, 63, 64, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94
Offset: 1
Keywords
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..100000
Programs
-
Python
from itertools import islice from sympy import isprime, nextprime def agen(): # generator of terms an, smc, smp = 2, 4, 3 yield from [1, 2] while True: if not isprime(an): an = smp if an == 2*smp else smc else: an = smp if smp < smc else smc if an == smp: smp = nextprime(smp) else: smc += 1 while isprime(smc): smc += 1 yield an print(list(islice(agen(), 87))) # Michael S. Branicky, Oct 03 2024
Comments