login
A215261
Write down the nonsemiprime numbers 1, 2, 3, 5, 7, 8, 11, 12, 13, 16, 17, ... and insert between two nonsemiprimes the smallest semiprime not yet present in the sequence such that two neighboring integers sum to a nonsemiprime.
2
1, 6, 2, 9, 3, 14, 5, 22, 7, 4, 8, 21, 11, 25, 12, 15, 13, 34, 16, 26, 17, 10, 18, 35, 19, 33, 20, 55, 23, 49, 24, 39, 27, 51, 28, 38, 29, 46, 30, 58, 31, 57, 32, 65, 36, 62, 37, 77, 40, 69, 41, 85, 42, 74, 43, 82, 44, 86, 45, 91, 47, 106, 48, 87, 50, 115, 52
OFFSET
1,2
COMMENTS
This is to semiprimes A001358 as A222307 is to primes A000040.
This is a permutation of the natural numbers A000027 with inverse permutation A211414.
MAPLE
issp:= n-> not isprime(n) and numtheory[bigomega](n)=2:
sp:= proc(n) option remember; local k; if n=1 then 4 else
for k from 1+sp(n-1) while not issp(k) do od; k fi end:
nsp:= proc(n) option remember; local k; if n=1 then 1 else
for k from 1+nsp(n-1) while issp(k) do od; k fi end:
g:= proc() true end:
a:= proc(n) option remember; local k, s;
if n>1 then a(n-1) fi;
if irem(n, 2, 'r')=1 then nsp(r+1)
else for k do s:=sp(k); if g(s) and not issp(nsp(r)+s) and
not issp(nsp(r+1)+s) then g(s):= false; return s fi od
fi
end:
seq(a(n), n=1..80);
MATHEMATICA
issp[n_] := !PrimeQ[n] && PrimeOmega[n] == 2;
sp[n_] := sp[n] = If[n == 1, 4, For[k = 1 + sp[n-1], !issp[k], k++]; k];
nsp[n_] := nsp[n] = If[n == 1, 1, For[k = 1 + nsp[n-1], issp[k], k++]; k];
Clear[g]; g[_] = True;
a[n_] := a[n] = Module[{q, r, k, s}, If[n>1, a[n-1]]; {q, r} = QuotientRemainder[n, 2]; If[r==1, nsp[q+1], For[k = 1, True, k++, s = sp[k]; If[g[s] && !issp[nsp[q] + s] && !issp[nsp[q+1] + s], g[s] = False; Return[s]]]]];
Table[a[n], {n, 1, 80}] (* Jean-François Alcover, Mar 24 2017, translated from Maple *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
STATUS
approved