OFFSET
1,1
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
Closest semiprimes to 4, 6, 9, 10, 14, 15, 21 are 6, 4, 10, 9, 15, 14, 22.
MATHEMATICA
csp[{a_, b_, c_}]:=If[c-b<b-a, c, a]; Join[{6}, csp/@Partition[Select[Range[ 300], PrimeOmega[#]==2&], 3, 1]] (* Harvey P. Dale, May 06 2014 *)
PROG
(Python)
from sympy import factorint
def semiprime(n): return sum(e for e in factorint(n).values()) == 2
def nextsemiprime(n):
nxt = n + 1
while not semiprime(nxt): nxt += 1
return nxt
def aupton(terms):
prv, cur, nxt, alst = 0, 4, 6, []
while len(alst) < terms:
alst.append(prv if 2*cur - prv <= nxt else nxt)
prv, cur, nxt = cur, nxt, nextsemiprime(nxt)
return alst
print(aupton(59)) # Michael S. Branicky, Jun 04 2021
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Jonathan Vos Post, Mar 25 2006
EXTENSIONS
Corrected by Harvey P. Dale, May 06 2014
STATUS
approved