OFFSET
1,2
COMMENTS
LINKS
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
Jonathan Vos Post and Alois P. Heinz, Feb 17 2013
STATUS
approved