A116946 Closest semiprime to n-th semiprime S that is different from S (break ties by taking the smaller semiprime).
6, 4, 10, 9, 15, 14, 22, 21, 26, 25, 34, 33, 34, 39, 38, 49, 51, 49, 57, 58, 57, 65, 62, 65, 77, 74, 85, 86, 85, 86, 93, 94, 93, 94, 111, 115, 118, 119, 118, 122, 121, 122, 133, 134, 133, 142, 141, 142, 146, 145, 158, 159, 158, 159, 169, 166, 178, 177, 185
Offset: 1
Examples
Closest semiprimes to 4, 6, 9, 10, 14, 15, 21 are 6, 4, 10, 9, 15, 14, 22.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
csp[{a_,b_,c_}]:=If[c-b
Harvey P. Dale, May 06 2014 *) -
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
Extensions
Corrected by Harvey P. Dale, May 06 2014