OFFSET
1,1
COMMENTS
Ulam numbers: a(1) = 1; a(2) = 2; for n>2, a(n) = least number > a(n-1) which is a unique sum of two distinct earlier terms.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
4 is a term because 4=2*2 is the product of 2 (not distinct) primes and 4 is an Ulam number.
6 is a term because 6=2*3 is the product of 2 distinct primes and 6 is an Ulam number.
57 is a term because 57=3*19 is the product of 2 distinct primes and 57 is an Ulam number.
MAPLE
N:= 5000: # for terms <= N
U:= [1, 2]: V:= Vector(N): V[3]:= 1: R:= NULL: count:= 0:
for i from 3 do
for k from U[-1]+1 to N do
if V[k] = 1 then
J:= select(`<=`, U +~ k, N);
V[J]:= V[J] +~ 1;
U:= [op(U), k];
if numtheory:-bigomega(k) = 2 then R:= R, k; count:= count+1; fi;
break
fi
od;
if k > N then break fi;
od:
R; # Robert Israel, Jan 24 2025
MATHEMATICA
seq[numUlams_] := Module[{ulams = {1, 2}}, Do[AppendTo[ulams, n = Last[ulams]; While[n++; Length[DeleteCases[Intersection[ulams, n - ulams], n/2, 1, 1]] != 2]; n], {numUlams}]; Select[ulams, PrimeOmega[#] == 2 &]]; seq[200] (* Amiram Eldar, Dec 07 2024, after Jean-François Alcover at A002858 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Massimo Kofler, Dec 07 2024
STATUS
approved