Home / Get Math Help
Ulam Sequence
Sequence description
a_1 = 1; a_2 = 2; subsequent terms are the lowest numbers which are unique sums of two distinct earlier terms
Sequence terms
1, 2, 3, 4, 6, 8, 11, 13, 16, 18, 26, 28, 36, 38, 47, 48, 53, 57, 62, 69, 72, 77, ...
Table program
Function[n, With[{Ulam = Compile[{{nmax, _Integer}, {init, _Integer, 1}, {s, _Integer}}, Module[{ulamhash = Table[0, {nmax}], ulam = init}, ulamhash[[ulam]] = 1; Do[If[Quotient[Plus @@ ulamhash[[i - ulam]], 2] == s, AppendTo[ulam, i]; ulamhash[[i]] = 1], {i, Last[init] + 1, nmax}]; ulam]]}, Ulam[14 n, {1, 2}, 1]]]
Plot