This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A002858 M0557 N0201 #300 Jul 16 2025 13:36:10 %S A002858 1,2,3,4,6,8,11,13,16,18,26,28,36,38,47,48,53,57,62,69,72,77,82,87,97, %T A002858 99,102,106,114,126,131,138,145,148,155,175,177,180,182,189,197,206, %U A002858 209,219,221,236,238,241,243,253,258,260,273,282,309,316,319,324,339 %N A002858 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. %C A002858 Ulam conjectured that this sequence has density 0. However, calculations up to 6.759*10^8 (_Jud McCranie_) indicate that the density hovers near 0.074. %C A002858 A plot of the first 3 million terms shows that they lie very close to the straight line 13.51*n, so even if we cannot prove it, we believe we now know how this sequence grows (see the plots in the links below). - _N. J. A. Sloane_, Sep 27 2006 %C A002858 After a few initial terms, the sequence settles into a regular pattern of dense clumps separated by sparse gaps, with period 21.601584+. This pattern continues up to at least a(n) = 5*10^6. (This comment is just a qualitative statement about the wavelike distribution of Ulam numbers, not meant to imply that every period includes Ulam numbers.) - _David W. Wilson_ %C A002858 _Don Knuth_ (Sep 26 2006) remarks that a(4952)=64420 and a(4953)=64682 (a gap of more than ten "dense clumps"); and there is a gap of 315 between a(18857) and a(18858). %C A002858 1,2,3,47 are the only values of x < 6.759*10^8 such that x and x+1 are both Ulam numbers. - _Jud McCranie_, Jun 08 2001. This holds through the first 28 billion Ulam numbers - _Jud McCranie_, Jan 07 2016. %C A002858 From _Jud McCranie_ on _David W. Wilson_'s illustration, Jun 20 2008: (Start) %C A002858 The integers are shown from left to right, top to bottom, with a dot where there is an Ulam number. I think his plot is 216 wide. The local density of Ulam numbers goes in waves with a period of 21.6+, so his plot shows ten cycles. %C A002858 When they are arranged that way you can see the waves. The crests of the density waves don't always have Ulam numbers there but the troughs are practically void of Ulam numbers. I noticed that the ratio of that period (21.6+) to the frequency of Ulam numbers (1 in 13.52) is very close to 8/5. (End) %C A002858 a(50000000) = 675904508. - _Jud McCranie_, Feb 29 2012 %C A002858 a(100000000) = 1351856726. - _Jud McCranie_, Jul 31 2012 %C A002858 a(1000000000) = 13517664323. - _Jud McCranie_, Aug 28 2015 %C A002858 a(28000000000) = 378485625853 - Philip Gibbs & _Jud McCranie_, Sep 09 2015 %C A002858 3 (=1+2) and 131 (=62+69) are the only two Ulam numbers in the first 28 billion Ulam numbers that are the sum of two consecutive Ulam numbers. - _Jud McCranie_, Jan 09 2016 %C A002858 Named after the Polish-American scientist Stanislaw Ulam (1909-1984). - _Amiram Eldar_, Jun 08 2021 %D A002858 Steven R. Finch, Mathematical Constants, Cambridge, 2003, Section 2.16.2. %D A002858 Richard K. Guy, Unsolved Problems in Number Theory, C4. %D A002858 Donald E. Knuth, The Art of Computer Programming, Volume 4A, Section 7.1.3. %D A002858 N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence). %D A002858 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence). %D A002858 James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, page 116. %D A002858 Marvin C. Wunderlich, The improbable behavior of Ulam's summation sequence, pp. 249-257 of A. O. L. Atkin and B. J. Birch, editors, Computers in Number Theory. Academic Press, NY, 1971. %D A002858 David Zeitlin, Ulam's sequence {U_n}, U_1=1, U_2=2, is a complete sequence, Notices Amer. Math. Soc., 22 (No. 7, 1975), Abstract 75T-A267, p. A-707. %H A002858 Jud McCranie, <a href="/A002858/b002858.txt">Table of n, a(n) for n = 1..10000</a> %H A002858 Richard A. Becker, <a href="/A002858/a002858.ps">Plot of residuals a(n) - 13.5167*n for n <= 3000000</a>, postscript file [uses Jud McCranie's values of a(n)]. %H A002858 Richard A. Becker, <a href="/A002858/a002858_1.pdf">Plot of residuals a(n) - 13.5167*n for n <= 3000000</a>, pdf file [uses Jud McCranie's values of a(n)]. %H A002858 Thomas Bloom, <a href="https://www.erdosproblems.com/342">Problem 342</a>, Erdős Problems. %H A002858 Henning Fernau and Kshitij Gajjar, <a href="https://arxiv.org/abs/2107.12973">The Space Complexity of Sum Labelling</a>, arXiv:2107.12973 [cs.DS], 2021. %H A002858 Steven R. Finch, <a href="/FinchSadd.html">Ulam s-Additive Sequences</a>. [From Steven Finch, Apr 20 2019] %H A002858 Steven R. Finch, <a href="http://www.people.fas.harvard.edu/~sfinch/constant/stlrsky/stlrsky.html">Stolarsky-Harborth Constant</a>. %H A002858 Steven R. Finch, <a href="http://web.archive.org/web/20010207195349/http://www.mathsoft.com/asolve/constant/stlrsky/stlrsky.html">Stolarsky-Harborth Constant</a>. [From the Wayback machine] %H A002858 Philip Gibbs, <a href="http://vixra.org/abs/1508.0085">An Efficient Way to Compute Ulam Numbers</a>. %H A002858 Philip Gibbs, <a href="http://vixra.org/abs/1508.0045">A Conjecture for Ulam Sequences</a>. %H A002858 Philip Gibbs and Judson McCranie, <a href="https://www.researchgate.net/profile/Philip_Gibbs/publication/320980165_The_Ulam_Numbers_up_to_One_Trillion/links/5a058786aca2726b4c78588d/The-Ulam-Numbers-up-to-One-Trillion.pdf">The Ulam Numbers up to One Trillion</a>, (2017). %H A002858 Shyam Sunder Gupta, <a href="https://doi.org/10.1007/978-981-97-2465-9_18">Ulam Numbers</a>. In: Exploring the Beauty of Fascinating Numbers. Springer Praxis Books(). Springer, Singapore, (2025). %H A002858 Alois P. Heinz, <a href="/A002858/a002858_1.png">Ulam spiral of Ulam numbers</a>. %H A002858 Donald E. Knuth, <a href="http://www-cs-faculty.stanford.edu/~knuth/programs.html">Downloadable programs</a> %H A002858 Noah Kravitz and Stefan Steinerberger, <a href="https://arxiv.org/abs/1705.01883">Ulam Sequences and Ulam Sets</a>, arXiv:1705.01883 [math.CO], 2017. %H A002858 Borys Kuca, <a href="https://arxiv.org/abs/1804.09594">Structures in Additive Sequences</a>, arXiv:1804.09594 [math.NT], 2018. See p. 3. %H A002858 Jud McCranie, <a href="/A002858/a002858.jpg">Density 10^2 to 10^12</a> %H A002858 Jud McCranie, <a href="/A002858/a002858_1.jpg">Density 10^4 to 10^12</a> %H A002858 Jud McCranie, <a href="/A002858/a002858_2.jpg">Density 10^6 to 10^12</a> %H A002858 J. W. Moon, R. K. Guy, and N. J. A. Sloane, <a href="/A003046/a003046.pdf">Correspondence, 1973</a>. %H A002858 Ed Pegg, Jr., <a href="http://www.wolframscience.com/preview/nks_pages/?NKS0908.gif">Graph of 10^6 terms of a(n) - 13.5*n</a>. %H A002858 Popular Computing (Calabasas, CA), <a href="/A003309/a003309.pdf">Sieves: Problem 43</a>, Vol. 2 (No. 13, Apr 1974), pp. 6-7. This is Sieve #8. [Annotated and scanned copy] %H A002858 R. Queneau, <a href="https://doi.org/10.1016/0097-3165(72)90083-0">Sur les suites s-additives</a>, J. Combin. Theory, A12 (1972), 31-71. %H A002858 Bernardo Recamán, <a href="http://www.jstor.org/stable/2319404">Questions on a sequence of Ulam</a>, Amer. Math. Monthly, Vol. 80, No. 8 (1973), pp. 919-920. %H A002858 Ivano Salvo and Agnese Pacifico, <a href="https://arxiv.org/abs/1807.11792">Computing Integer Sequences: Filtering vs Generation (Functional Pearl)</a>, arXiv:1807.11792 [cs.PL], 2018. %H A002858 James Schmerl and Eugene Spiegel, <a href="https://doi.org/10.1016/0097-3165(94)90058-2">The regularity of some 1-additive sequences</a>, J. Combin. Theory. Ser. A, Vol. 66, No. 1 (1994), pp. 172-175. Math. Rev. 95h:11010. %H A002858 Arseniy Sheydvasser, <a href="https://arxiv.org/abs/1910.00109">The Ulam Sequence of the Integer Polynomial Ring</a>, arXiv:1910.00109 [math.NT], 2019. %H A002858 N. J. A. Sloane, <a href="/A001149/a001149.pdf">Handwritten notes on Self-Generating Sequences, 1970</a> (note that A1148 has now become A005282). %H A002858 Arseniy (Senia) Sheydvasser, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL24/Sheydvasser/sheyd3.html">The Ulam Sequence of Linear Integer Polynomials</a>, J. Int. Seq., Vol. 24 (2021), Article 21.10.8. %H A002858 Stefan Steinerberger, <a href="http://cpsc.yale.edu/sites/default/files/files/tr1508.pdf">A hidden signal in the Ulam sequence</a>, Research Report YALEU/DCS/TR-1508, Yale University, 2015. %H A002858 Stefan Steinerberger, <a href="/A002858/a002858_2.png">A hidden signal in the Ulam sequence</a>, Figure 2 from Research Report YALEU/DCS/TR-1508, Yale University, 2015. %H A002858 Stefan Steinerberger, <a href="https://gilkalai.wordpress.com/2016/04/12/stefan-steinerberger-the-ulam-sequence/">The Ulam Sequence</a>, blog post, April 12, 2016. %H A002858 Stanislaw M. Ulam, <a href="/A002858/a002858.pdf">On some mathematical problems connected with patterns of growth of figures</a>, pp. 215-224 of R. E. Bellman, ed., Mathematical Problems in the Biological Sciences, Proc. Sympos. Applied Math., Vol. 14, Amer. Math. Soc., 1962 [Annotated scanned copy] %H A002858 Stanislaw Ulam, <a href="https://doi.org/10.1137/1006090">Combinatorial analysis in infinite sets and some physical theories</a>, SIAM Rev., Vol. 6, No. 4 (1964), pp. 343-355. Reprinted in Selected Papers, MIT Press, see p. 393. %H A002858 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/UlamSequence.html">Ulam Sequence</a>. %H A002858 Wikipedia, <a href="http://en.wikipedia.org/wiki/Ulam_number">Ulam number</a>. %H A002858 David W. Wilson, <a href="/A002858/a002858.png">Plot of initial terms</a>, showing their quasiperiodicity as vertical bars. The image width was chosen to include approximately 10 periods. For an explanation of this picture, see Comments above. %H A002858 Robert G. Wilson v, <a href="/A002858/a002858_3.pdf">Letter to N. J. A. Sloane, Sep. 1992</a>. %H A002858 David Zeitlin, <a href="/A002858/a002858_2.pdf">Ulam's sequence {U_n}, U_1=1, U_2=2, is a complete sequence</a>, Notices Amer. Math. Soc., 22 (No. 7, 1975), Abstract 75T-A267, p. A-707. (Annotated scanned copy) %H A002858 <a href="/index/U#Ulam_num">Index entries for Ulam numbers</a> %p A002858 UlamList := proc(len) local isUlam, nextUlam, behead; behead := u -> u[2..numelems(u)]; isUlam := proc(n, h, u, r) local hu, tu, hr, tr; hu := u[1]; hr := r[1]; if h = 2 then return false fi; if hr <= hu then return evalb(h = 1) fi; if (hr + hu) = n then tu := behead(u); tr := behead(r); return isUlam(n, h+1, tu, tr) fi; if (hr + hu) < n then tu := behead(u): return isUlam(n, h, tu, r) fi; tr := behead(r); isUlam(n, h, u, tr) end: nextUlam := proc(n, u, r) if isUlam(n, 0, u, r) then if nops(u) = len-1 then return [op(u), n] fi; nextUlam(n+1, [op(u), n], [n, op(r)]) else nextUlam(n+1, u, r) fi end: nextUlam(3, [1, 2], [2, 1]) end: %p A002858 UlamList(59); # _Peter Luschny_, Apr 05 2019 %t A002858 Ulam4Compiled = 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]]; ulams = Ulam4Compiled[355, {1, 2}, 1] %t A002858 (* Second program: *) %t A002858 ulams = {1, 2}; Do[AppendTo[ulams, n = Last[ulams]; While[n++; Length[DeleteCases[Intersection[ulams, n - ulams], n/2, 1, 1]] != 2]; n], {100}]; ulams (* _Jean-François Alcover_, Sep 08 2011 *) %t A002858 findUlams[s_List, j_Integer] := Block[{k = s[[-1]] + 1, ss = Plus @@@ Subsets[s, {j}]}, While[ Count[ss, k] != 1, k++]; Append[s, k]]; ulams = Nest[findUlams[#, 2] &, {1, 2}, 70] (* _Robert G. Wilson v_, Jul 05 2014 *) %o A002858 (Haskell) %o A002858 a002858 n = a002858_list !! (n-1) %o A002858 a002858_list = 1 : 2 : ulam 2 2 a002858_list %o A002858 ulam :: Int -> Integer -> [Integer] -> [Integer] %o A002858 ulam n u us = u' : ulam (n + 1) u' us where %o A002858 u' = f 0 (u+1) us' %o A002858 f 2 z _ = f 0 (z + 1) us' %o A002858 f e z (v:vs) | z - v <= v = if e == 1 then z else f 0 (z + 1) us' %o A002858 | z - v `elem` us' = f (e + 1) z vs %o A002858 | otherwise = f e z vs %o A002858 us' = take n us %o A002858 -- _Reinhard Zumkeller_, Nov 03 2011 %o A002858 (Python) %o A002858 def isUlam(n, h, u, r): %o A002858 if h == 2: return False %o A002858 hu = u[0]; hr = r[0] %o A002858 if hr <= hu: return h == 1 %o A002858 if hr + hu > n: r = r[1:] %o A002858 elif hr + hu < n: u = u[1:] %o A002858 else: h += 1; r = r[1:]; u = u[1:] %o A002858 return isUlam(n, h, u, r) %o A002858 def UlamList(length): %o A002858 u = [1, 2]; r = [2, 1]; n = 2 %o A002858 while len(u) < length: %o A002858 n += 1 %o A002858 if isUlam(n, 0, u[:], r[:]): %o A002858 u.append(n); r.insert(0, n) %o A002858 return u %o A002858 print(UlamList(59)) # _Peter Luschny_, Apr 06 2019 %o A002858 (Julia) %o A002858 function isUlam(u, n, h, i, r) %o A002858 h == 2 && return false %o A002858 ur = u[r]; ui = u[i] %o A002858 ur <= ui && return h == 1 %o A002858 if ur + ui > n %o A002858 r -= 1 %o A002858 elseif ur + ui < n %o A002858 i += 1 %o A002858 else %o A002858 h += 1; i += 1; r -= 1 %o A002858 end %o A002858 isUlam(u, n, h, i, r) %o A002858 end %o A002858 function UlamList(len) %o A002858 u = Array{Int, 1}(undef, len) %o A002858 u[1] = 1; u[2] = 2; i = 2; n = 2 %o A002858 while i < len %o A002858 n += 1 %o A002858 if isUlam(u, n, 0, 1, i) %o A002858 i += 1 %o A002858 u[i] = n %o A002858 end %o A002858 end %o A002858 return u %o A002858 end %o A002858 println(UlamList(59)) # _Peter Luschny_, Apr 07 2019 %o A002858 (PARI) aupto(N)= my(seen=vector(N), U=[]); seen[1]=seen[2]=1; for(i=1,N, if(1==seen[i], for(j=1,#U, my(sum=i+U[j]); if(sum>N, break); seen[sum]++); U=concat(U,i))); U \\ _Ruud H.G. van Tol_, Dec 29 2022 %Y A002858 Cf. A002859 (version beginning 1,3), A054540, A003667, A001857, A007300, A117140, A214603. %Y A002858 First differences: A072832, A072540. %Y A002858 Cf. A080287, A080288, A004280 (if distinct removed from definition). %Y A002858 Cf. A199016, A199017, A033629, A274522. %Y A002858 See also the density plots in A080573 and A285884. %K A002858 nonn,nice %O A002858 1,2 %A A002858 _N. J. A. Sloane_ %E A002858 More terms from _Jud McCranie_