cp's OEIS Frontend

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.

Showing 1-10 of 60 results. Next

A080200 Numbers that do not occur as differences between terms of the Mian-Chowla sequence A005282.

Original entry on oeis.org

33, 88, 98, 99, 105, 106, 112, 126, 130, 132, 134, 150, 152, 154, 156, 162, 163, 165, 170, 176, 184, 188, 198, 205, 214, 215, 217, 220, 222, 228, 234, 235, 240, 246, 252, 255, 263, 266, 267, 268, 274, 276, 279, 281, 287, 290, 291, 294, 297, 302
Offset: 1

Views

Author

Hugo Pfoertner, Feb 05 2003

Keywords

Comments

This sequence was suggested by Jens Voß, Feb 04 2003. Terms are only conjectures. Elements might be eliminated by higher terms of A005282, which was checked up to 4*10^6.
Terms through a(50) confirmed by checking against first 25000 terms of A005282. - Hugo Pfoertner, Nov 13 2021

References

Crossrefs

Programs

  • Fortran
    ! See Links section.

Extensions

Corrected and extended by T. D. Noe, Mar 29 2007

A133097 a(n) = A005282(n) - A011185(n-1).

Original entry on oeis.org

0, 0, 1, 3, 5, 8, 10, 15, 27, 28, 23, 28, 20, 30, 22, 40, 32, 45, 27, 62, 89, 62, 116, 167, 105, 118, 108, 51, 99, 151, 88, 137, 137, 265, 174, 195, 320, 321, 249, 283, 226, 281, 293, 394, 465, 369, 585, 565, 639, 404, 483, 221, 233, 428, 384, 370, 527, 431, 818
Offset: 1

Views

Author

Klaus Brockhaus, Sep 17 2007

Keywords

Comments

Also A025582(n) - A010672(n-1).
A005282 is the sequence of smallest numbers such that the pairwise sums of not necessarily distinct elements are all distinct, whereas A011185 is the sequence of smallest numbers such that the pairwise sums of distinct elements are all distinct.
Sequence has negative terms; the first one is a(65) = -130.

Examples

			a(6) = A005282(6) - A011185(6) = 21 - 13 = 8.
		

Crossrefs

Programs

  • Python
    from itertools import count, islice
    from collections import deque
    def A133097_gen(): # generator of terms
        aset2, alist, bset2, blist, aqueue, bqueue = set(), [], set(), [], deque(), deque()
        for k in count(1):
            cset2 = {k<<1}
            if (k<<1) not in aset2:
                for a in alist:
                    if (m:=a+k) in aset2:
                        break
                    cset2.add(m)
                else:
                    aqueue.append(k)
                    alist.append(k)
                    aset2.update(cset2)
            cset2 = set()
            for b in blist:
                if (m:=b+k) in bset2:
                    break
                cset2.add(m)
            else:
                bqueue.append(k)
                blist.append(k)
                bset2.update(cset2)
            if len(aqueue) > 0 and len(bqueue) > 0:
                yield aqueue.popleft()-bqueue.popleft()
    A133097_list = list(islice(A133097_gen(),30)) # Chai Wah Wu, Sep 11 2023

A080222 Record-setting differences between adjacent elements of the Mian-Chowla sequence A005282.

Original entry on oeis.org

1, 2, 4, 5, 8, 10, 14, 21, 26, 34, 48, 71, 74, 90, 113, 143, 153, 249, 270, 299, 346, 453, 535, 940, 1052, 1226, 1347, 1365, 2443, 2511, 4253, 4254, 6116, 7339, 8898, 13621, 15567, 17940, 21061, 21307, 25558, 35749, 39437, 46664, 62709
Offset: 1

Views

Author

Hugo Pfoertner, Feb 07 2003

Keywords

Examples

			a(12)=71 because A005282(17)-A005282(16)=361-290=71 is greater than all previous differences. a(45)=A005282(619)-A005282(618)=3738616-3675907=62709
		

References

Crossrefs

A133604 Elements of A005282 that are also the sum of a pair of not necessarily distinct elements of A005282.

Original entry on oeis.org

2, 4, 8, 21, 66, 97, 204, 565, 662, 775, 970, 1821, 2780, 6374, 8730, 8942, 10898, 24596, 55307, 67189, 79047, 84345, 164868, 231694, 233570, 234619, 271511, 298414, 433973, 474668, 475800, 567408, 829129, 839728, 889285, 1394240
Offset: 1

Views

Author

Klaus Brockhaus, Sep 18 2007

Keywords

Comments

A005282 is the sequence of smallest numbers such that the pairwise sums of not necessarily distinct elements are all distinct.
Conjecture: 2, 4 and 8 are the only terms n such that n = 2*A005282(k) for some k.

Examples

			A005282(3) = 4 + 4 = 8 = A005282(4), hence 8 is in the sequence.
A005282(10) = 81, A005282(12) = 123. 81 + 123 = 204 = A005282(15), hence 204 is in the sequence.
		

Crossrefs

Programs

  • Python
    from itertools import count, islice
    def A133604_gen(): # generator of terms
        aset2, alist = set(), []
        for k in count(1):
            bset2 = {r:=k<<1}
            if r not in aset2:
                for d in alist:
                    if (m:=d+k) in aset2:
                        break
                    bset2.add(m)
                else:
                    if k in aset2:
                        yield k
                    alist.append(k)
                    aset2.update(bset2)
    A133604_list = list(islice(A133604_gen(),30)) # Chai Wah Wu, Sep 11 2023

A080933 Smallest non-occurring pairwise difference between the elements of a Mian-Chowla sequence (A005282) variant starting with (1,n).

Original entry on oeis.org

33, 49, 26, 15, 30, 19, 44, 13, 38, 50, 54, 58, 44, 46, 25, 20, 45, 10, 13, 84, 38, 15, 71, 33, 35, 54, 31, 16, 57, 10, 42, 26, 15, 14, 33, 14, 15, 32, 34, 16, 25, 28, 25, 16, 36, 16, 16, 25, 28, 40, 16, 31, 33, 28, 15, 31, 15, 22, 31, 33, 15, 21, 49, 51, 28
Offset: 2

Views

Author

Hugo Pfoertner, Feb 24 2003

Keywords

Comments

For large n the sequence consists of increasingly long runs of "33", which is the first term of A080200 (the smallest non-occurring difference in A005282), with some interspersed other terms. E.g. for n=100000..100100 we have a(n)=88 for n=100005,100021,100041,100087,100099, a(100072)=98 and otherwise a(n)=33.

Examples

			a(2)=33 because the smallest non-occurring pairwise difference between the terms of A005282 (starting with 1,2) is A080200(1)=33. a(3)=49 because the smallest non-occurring pairwise difference between the terms of A051788 (starting with 1,3) is A080201(1)=49. a(4)=26 because the smallest non-occurring pairwise difference between the terms of A058335 (starting with 1,4) is A080932(1)=26.
		

References

Crossrefs

A259964 A specially constructed B_2 sequence with sum of reciprocals greater than that of the Mian-Chowla sequence A005282.

Original entry on oeis.org

1, 2, 4, 8, 13, 21, 31, 45, 66, 81, 97, 123, 148, 182, 229, 257, 290, 312, 381, 419, 467, 507, 621, 721, 770, 864, 927, 1050, 1178, 1289, 1457, 1561, 1615, 1774, 1907, 2090, 2164, 2263, 2309, 2539, 2800, 2938, 3035, 3310, 3380, 3738, 4043, 4239, 4439, 4726, 4851, 5016, 5169, 5289, 5490, 5760, 6646, 6843, 7015, 7442, 7674, 7986, 8284, 8506, 8772, 9240, 9778, 9996, 10344, 10431, 11614, 12263
Offset: 1

Views

Author

N. J. A. Sloane, Jul 11 2015

Keywords

Comments

Constructed using the greedy algorithm (as for A005252) except at 15th term, which is 229.
It had been conjectured that the sum of reciprocals for B_2 sequences was maximized by A005282. This sequence gives a counterexample.

Crossrefs

Cf. A005282.

A000002 Kolakoski sequence: a(n) is length of n-th run; a(1) = 1; sequence consists just of 1's and 2's.

Original entry on oeis.org

1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2
Offset: 1

Views

Author

Keywords

Comments

Historical note: the sequence might be better called the Oldenburger-Kolakoski sequence, since it was discussed by Rufus Oldenburger in 1939; see links. - Clark Kimberling, Dec 06 2012. However, to avoid confusion, this sequence will be known in the OEIS as the Kolakoski sequence. It is undesirable to have some entries refer to the Oldenburger-Kolakoski sequence and others to the Kolakoski sequence. - N. J. A. Sloane, Nov 22 2017
It is an unsolved problem to show that the density of 1's is equal to 1/2.
A weaker problem is to construct a combinatorial bijection between the set of positions of 1's and the set of positions of 2's. - Gus Wiseman, Mar 01 2016
The sequence is cubefree and all square subwords have lengths which are one of 2, 4, 6, 18 and 54 (see A294447) [Carpi, 1994].
This is a fractal sequence: replace each run with its length and recover the original sequence. - Kerry Mitchell, Dec 08 2005
Kupin and Rowland write: We use a method of Goulden and Jackson to bound freq_1(K), the limiting frequency of 1 in the Kolakoski word K. We prove that |freq_1(K) - 1/2| <= 17/762, assuming the limit exists and establish the semirigorous bound |freq_1(K) - 1/2| <= 1/46. - Jonathan Vos Post, Sep 16 2008
freq_1(K) is conjectured to be 1/2 + O(log(K)) (see PlanetMath link). - Jon Perry, Oct 29 2014
Conjecture: Taking the sequence in word lengths of 10, for example, batch 1-10, 11-20, etc., then there can only be 4, 5 or 6 1's in each batch. - Jon Perry, Sep 26 2012
From Jean-Christophe Hervé, Oct 04 2014: (Start)
The sequence does not contain words of the form ababa, because this would imply the impossible 111 (1 b, 1 a, 1 b) somewhere before. This demonstrates the conjecture made by Jon Perry: more than 6 1's or 6 2's in a word of 10 would necessitate something like aabaabaaba, which would imply the impossible 12121 before (word aabaababaa is also impossible because of ababa). The remark on the sextuplets below even shows that the number of 1's in any 9-tuplet is always 4 or 5.
There are only 6 triples that appear in the sequence (112, 121, 122, 211, 212 and 221); and by the preceding argument, only 18 sextuplets: the 6 double triples (112112, etc.); 112122, 112212, 121122, 121221, 211212, and 211221; and those obtained by reversing the order of the triples (122112, etc.). Regarding the density of 1's in the sequence, these 12 sextuplets all have a density 1/2 of 1's, and the 6 double triples all lead to a word with this exact density after transformation by the Kolakoski rules, for example: 112112 -> 12112122 (4 1's/8); this is because the second triple reverses the numbers of 1's and 2's generated by the first triple. Therefore, the sequence can be split into the double triples on one side, a part whose transformation (which is in the sequence) has a density of 1's of 1/2; and a part with the other sextuplets, which has directly the same density of 1's. (End)
If we map 1 to +1 and 2 to -1, then the mapped sequence would have a [conjectured] mean of 0, since the Kolakoski sequence is [conjectured] to have an equal density (1/2) of 1s and 2s. For the partial sums of this mapped sequence, see A088568. - Daniel Forgues, Jul 08 2015
Looking at the plot for A088568, it seems that although the asymptotic densities of 1s and 2s appear to be 1/2, there might be a bias in favor of the 2s. I.e., D(1) = 1/2 - O(log(n)/n), D(2) = 1/2 + O(log(n)/n). - Daniel Forgues, Jul 11 2015
From Michel Dekking, Jan 31 2018: (Start)
(a(n)) is the unique fixed point of the 2-block substitution beta
11 -> 12
12 -> 122
21 -> 112
22 -> 1122.
A 2-block substitution beta maps a word w(1)...w(2n) to the word
beta(w(1)w(2))...beta(w(2n-1)w(2n)).
If the word has odd length, then the last letter is ignored.
It was noted by me in 1979 in the Bordeaux seminar on number theory that (a(n+1)) is fixed point of the 2-block substitution 11 -> 21, 12 -> 211, 21 -> 221, 22 -> 2211. (End)
Named after the American artist and recreational mathematician William George Kolakoski (1944-1997). - Amiram Eldar, Jun 17 2021

Examples

			Start with a(1) = 1. By definition of the sequence, this says that the first run has length 1, so it must be a single 1, and a(2) = 2. Thus, the second run (which starts with this 2) must have length 2, so the third term must be also be a(3) = 2, and the fourth term can't be a 2, so must be a(4) = 1. Since a(3) = 2, the third run must have length 2, so we deduce a(5) = 1, a(6) = 2, and so on. The correction I made was to change a(4) to a(5) and a(5) to a(6). - _Labos Elemer_, corrected by _Graeme McRae_
		

References

  • Jean-Paul Allouche and Jeffrey Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 337.
  • Éric Angelini, "Jeux de suites", in Dossier Pour La Science, pp. 32-35, Volume 59 (Jeux math'), April/June 2008, Paris.
  • F. M. Dekking, What Is the Long Range Order in the Kolakoski Sequence?, in The mathematics of long-range aperiodic order (Waterloo, ON, 1995), 115-125, NATO Adv. Sci. Inst. Ser. C Math. Phys. Sci., 489, Kluwer Acad. Publ., Dordrecht, 1997. Math. Rev. 98g:11022.
  • Michael S. Keane, Ergodic theory and subshifts of finite type, Chap. 2 of T. Bedford et al., eds., Ergodic Theory, Symbolic Dynamics and Hyperbolic Spaces, Oxford, 1991, esp. p. 50.
  • J. C. Lagarias, Number Theory and Dynamical Systems, pp. 35-72 of S. A. Burr, ed., The Unreasonable Effectiveness of Number Theory, Proc. Sympos. Appl. Math., 46 (1992). Amer. Math. Soc.
  • Michel Rigo, Formal Languages, Automata and Numeration Systems, 2 vols., Wiley, 2014. Mentions this sequence - see "List of Sequences" in Vol. 2.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • Ilan Vardi, Computational Recreations in Mathematica. Addison-Wesley, Redwood City, CA, 1991, p. 233.

Crossrefs

Cf. A054354, bisections: A100428, A100429.
Cf. A013947, A156077, A234322 (positions, running total and percentage of 1's).
Cf. A118270.
Cf. A049705, A088569 (are either subsequences of A000002? - Jon Perry, Oct 30 2014)
Kolakoski-type sequences using other seeds than (1,2):
A078880 (2,1), A064353 (1,3), A071820 (2,3), A074804 (3,2), A071907 (1,4), A071928 (2,4), A071942 (3,4), A074803 (4,2), A079729 (1,2,3), A079730 (1,2,3,4).
Other self-describing: A001462 (Golomb sequence, see also references therein), A005041, A100144.
Cf. A088568 (partial sums of [3 - 2 * a(n)]).

Programs

  • Haskell
    a = 1:2: drop 2 (concat . zipWith replicate a . cycle $ [1,2]) -- John Tromp, Apr 09 2011
    
  • Maple
    M := 100; s := [ 1,2,2 ]; for n from 3 to M do for i from 1 to s[ n ] do s := [ op(s),1+((n-1)mod 2) ]; od: od: s; A000002 := n->s[n];
    # alternative implementation based on the Cloitre formula:
    A000002 := proc(n)
        local ksu,k ;
        option remember;
        if n = 1 then
            1;
        elif n <=3 then
            2;
        else
            for k from 1 do
                ksu := add(procname(i),i=1..k) ;
                if n = ksu then
                    return (3+(-1)^k)/2 ;
                elif n = ksu+ 1 then
                    return (3-(-1)^k)/2 ;
                end if;
            end do:
        end if;
    end proc: # R. J. Mathar, Nov 15 2014
  • Mathematica
    a[steps_] := Module[{a = {1, 2, 2}}, Do[a = Append[a, 1 + Mod[(n - 1), 2]], {n, 3, steps}, {i, a[[n]]}]; a]
    a[ n_] := If[ n < 3, Max[ 0, n], Module[ {an = {1, 2, 2}, m = 3}, While[ Length[ an] < n, an = Join[ an, Table[ Mod[m, 2, 1], { an[[ m]]} ]]; m++]; an[[n]]]] (* Michael Somos, Jul 11 2011 *)
    n=8; Prepend[ Nest[ Flatten[ Partition[#, 2] /. {{2, 2} -> {2, 2, 1, 1}, {2, 1} -> {2, 2, 1}, {1, 2} -> {2, 1, 1}, {1, 1} -> {2, 1}}] &, {2, 2}, n], 1] (* Birkas Gyorgy, Jul 10 2012 *)
    KolakoskiSeq[n_Integer] := Block[{a = {1, 2, 2}}, Fold[Join[#1, ConstantArray[Mod[#2, 2, 1], #1[[#2]]]] &, a, Range[3, n]]]; KolakoskiSeq[999] (* Mikk Heidemaa, Nov 01 2024 *) (* Corrected by Giorgos Kalogeropoulos, May 09 2025 *)
  • PARI
    my(a=[1,2,2]); for(n=3,80, for(i=1,a[n],a=concat(a,2-n%2))); a
    
  • PARI
    {a(n) = local(an=[1, 2, 2], m=3); if( n<1, 0, while( #an < n, an = concat( an, vector(an[m], i, 2-m%2)); m++); an[n])};
    
  • Python
    # For explanation see link.
    def Kolakoski():
        x = y = -1
        while True:
            yield [2,1][x&1]
            f = y &~ (y+1)
            x ^= f
            y = (y+1) | (f & (x>>1))
    K = Kolakoski()
    print([next(K) for  in range(100)]) # _David Eppstein, Oct 15 2016

Formula

These two formulas define completely the sequence: a(1)=1, a(2)=2, a(a(1) + a(2) + ... + a(k)) = (3 + (-1)^k)/2 and a(a(1) + a(2) + ... + a(k) + 1) = (3 - (-1)^k)/2. - Benoit Cloitre, Oct 06 2003
a(n+2)*a(n+1)*a(n)/2 = a(n+2) + a(n+1) + a(n) - 3 (this formula doesn't define the sequence, it is just a consequence of the definition). - Benoit Cloitre, Nov 17 2003
a(n+1) = 3 - a(n) + (a(n) - a(n-1))*(a(b(n)) - 1), where b(n) is the sequence A156253. - Jean-Marc Fedou and Gabriele Fici, Mar 18 2010
a(n) = (3 + (-1)^A156253(n))/2. - Benoit Cloitre, Sep 17 2013
Conjectures from Boštjan Gec, Oct 07 2024: (Start)
a(n)*(a(n-1) + a(n-2) - 3) + a(n-1)*a(n-2) + 7 = 3*a(n-1) + 3*a(n-2).
a(n)*(a(n-1) + a(n-2) - 3) = a(n-3)*(a(n-1) + a(n-2) - 3). (End)
Comment from Kevin Ryde, Oct 07 2024: The above formulas are true: The parts identify when terms are same or different and they hold for any sequence of 1's and 2's with run lengths 1 or 2.

Extensions

Minor edits to example and PARI code made by M. F. Hasler, May 07 2014

A002024 k appears k times; a(n) = floor(sqrt(2n) + 1/2).

Original entry on oeis.org

1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13
Offset: 1

Views

Author

Keywords

Comments

Integer inverse function of the triangular numbers A000217. The function trinv(n) = floor((1+sqrt(1+8n))/2), n >= 0, gives the values 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, ..., that is, the same sequence with offset 0. - N. J. A. Sloane, Jun 21 2009
Array T(k,n) = n+k-1 read by antidiagonals.
Eigensequence of the triangle = A001563. - Gary W. Adamson, Dec 29 2008
Can apparently also be defined via a(n+1)=b(n) for n >= 2 where b(0)=b(1)=1 and b(n) = b(n-b(n-2))+1. Tested to be correct for all n <= 150000. - José María Grau Ribas, Jun 10 2011
For any n >= 0, a(n+1) is the least integer m such that A000217(m)=m(m+1)/2 is larger than n. This is useful when enumerating representations of n as difference of triangular numbers; see also A234813. - M. F. Hasler, Apr 19 2014
Number of binary digits of A023758, i.e., a(n) = ceiling(log_2(A023758(n+2))). - Andres Cicuttin, Apr 29 2016
a(n) and A002260(n) give respectively the x(n) and y(n) coordinates of the sorted sequence of points in the integer lattice such that x(n) > 0, 0 < y(n) <= x(n), and min(x(n), y(n)) < max(x(n+1), y(n+1)) for n > 0. - Andres Cicuttin, Dec 25 2016
Partial sums (A060432) are given by S(n) = (-a(n)^3 + a(n)*(1+6n))/6. - Daniel Cieslinski, Oct 23 2017
As an array, T(k,n) is the number of digits columns used in carryless multiplication between a k-digit number and an n-digit number. - Stefano Spezia, Sep 24 2022
a(n) is the maximum number of possible solutions to an n-statement Knights and Knaves Puzzle, where each statement is of the form "x of us are knights" for some 1 <= x <= n, knights can only tell the truth and knaves can only lie. - Taisha Charles and Brittany Ohlinger, Jul 29 2023

Examples

			From _Clark Kimberling_, Sep 16 2008: (Start)
As a rectangular array, a northwest corner:
  1 2 3 4 5 6
  2 3 4 5 6 7
  3 4 5 6 7 8
  4 5 6 7 8 9
This is the weight array (cf. A144112) of A107985 (formatted as a rectangular array). (End)
G.f. = x + 2*x^2 + 2*x^3 + 3*x^4 + 3*x^5 + 3*x^6 + 4*x^7 + 4*x^9 + 4*x^9 + 4*x^10 + ...
		

References

  • Edward S. Barbeau, Murray S. Klamkin, and William O. J. Moser, Five Hundred Mathematical Challenges, Prob. 441, pp. 41, 194. MAA 1995.
  • R. L. Graham, D. E. Knuth, and O. Patashnik, Concrete Mathematics. Addison-Wesley, Reading, MA, 1990, p. 97.
  • K. Hardy and K. S. Williams, The Green Book of Mathematical Problems, p. 59, Solution to Prob. 14, Dover NY, 1985
  • R. Honsberger, Mathematical Morsels, pp. 133-134, MAA 1978.
  • J. F. Hurley, Litton's Problematical Recreations, pp. 152; 313-4 Prob. 22, VNR Co., NY, 1971.
  • D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, Vol. 1, p. 43.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • S. Wolfram, A New Kind of Science, Wolfram Media, 2002; p. 129.

Crossrefs

a(n+1) = 1+A003056(n), A022846(n)=a(n^2), a(n+1)=A002260(n)+A025581(n).
A123578 is an essentially identical sequence.

Programs

  • Haskell
    a002024 n k = a002024_tabl !! (n-1) !! (k-1)
    a002024_row n = a002024_tabl !! (n-1)
    a002024_tabl = iterate (\xs@(x:_) -> map (+ 1) (x : xs)) [1]
    a002024_list = concat a002024_tabl
    a002024' = round . sqrt . (* 2) . fromIntegral
    -- Reinhard Zumkeller, Jul 05 2015, Feb 12 2012, Mar 18 2011
    
  • Haskell
    a002024_list = [1..] >>= \n -> replicate n n
    
  • Haskell
    a002024 = (!!) $ [1..] >>= \n -> replicate n n
    -- Sascha Mücke, May 10 2016
    
  • Magma
    [Floor(Sqrt(2*n) + 1/2): n in [1..80]]; // Vincenzo Librandi, Nov 19 2014
    
  • Maple
    A002024 := n-> ceil((sqrt(1+8*n)-1)/2); seq(A002024(n), n=1..100);
  • Mathematica
    a[1] = 1; a[n_] := a[n] = a[n - a[n - 1]] + 1 (* Branko Curgus, May 12 2009 *)
    Table[n, {n, 13}, {n}] // Flatten (* Robert G. Wilson v, May 11 2010 *)
    Table[PadRight[{},n,n],{n,15}]//Flatten (* Harvey P. Dale, Jan 13 2019 *)
  • PARI
    t1(n)=floor(1/2+sqrt(2*n)) /* A002024 = this sequence */
    
  • PARI
    t2(n)=n-binomial(floor(1/2+sqrt(2*n)),2) /* A002260(n-1) */
    
  • PARI
    t3(n)=binomial(floor(3/2+sqrt(2*n)),2)-n+1 /* A004736 */
    
  • PARI
    t4(n)=n-1-binomial(floor(1/2+sqrt(2*n)),2) /* A002260(n-1)-1 */
    
  • PARI
    A002024(n)=(sqrtint(n*8)+1)\2 \\ M. F. Hasler, Apr 19 2014
    
  • PARI
    a(n)=(sqrtint(8*n-7)+1)\2
    
  • PARI
    a(n)=my(k=1);while(binomial(k+1,2)+1<=n,k++);k \\ R. J. Cano, Mar 17 2014
    
  • Python
    from math import isqrt
    def A002024(n): return (isqrt(8*n)+1)//2 # Chai Wah Wu, Feb 02 2022
  • Sage
    [floor(sqrt(2*n) +1/2) for n in (1..80)] # G. C. Greubel, Dec 10 2018
    

Formula

a(n) = floor(1/2 + sqrt(2n)). Also a(n) = ceiling((sqrt(1+8n)-1)/2). [See the Liu link for a large collection of explicit formulas. - N. J. A. Sloane, Oct 30 2019]
a((k-1)*k/2 + i) = k for k > 0 and 0 < i <= k. - Reinhard Zumkeller, Aug 30 2001
a(n) = a(n - a(n-1)) + 1, with a(1)=1. - Ian M. Levitt (ilevitt(AT)duke.poly.edu), Aug 18 2002
a(n) = round(sqrt(2n)). - Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Nov 01 2002
T(n,k) = A003602(A118413(n,k)); = T(n,k) = A001511(A118416(n,k)). - Reinhard Zumkeller, Apr 27 2006
G.f.: (x/(1-x))*Product_{k>0} (1-x^(2*k))/(1-x^(2*k-1)). - Vladeta Jovovic, Oct 06 2003
Equals A127899 * A004736. - Gary W. Adamson, Feb 09 2007
Sum_{i=1..n} Sum_{j=i..n+i-1} T(j,i) = A000578(n); Sum_{i=1..n} T(n,i) = A000290(n). - Reinhard Zumkeller, Jun 24 2007
a(n) + n = A014132(n). - Vincenzo Librandi, Jul 08 2010
a(n) = ceiling(-1/2 + sqrt(2n)). - Branko Curgus, May 12 2009
a(A169581(n)) = A038567(n). - Reinhard Zumkeller, Dec 02 2009
a(n) = round(sqrt(2*n)) = round(sqrt(2*n-1)); there exist a and b greater than zero such that 2*n = 2+(a+b)^2 -(a+3*b) and a(n)=(a+b-1). - Fabio Civolani (civox(AT)tiscali.it), Feb 23 2010
A005318(n+1) = 2*A005318(n) - A205744(n), A205744(n) = A005318(A083920(n)), A083920(n) = n - a(n). - N. J. A. Sloane, Feb 11 2012
Expansion of psi(x) * x / (1 - x) in powers of x where psi() is a Ramanujan theta function. - Michael Somos, Mar 19 2014
G.f.: (x/(1-x)) * Product_{n>=1} (1 + x^n) * (1 - x^(2*n)). - Paul D. Hanna, Feb 27 2016
a(n) = 1 + Sum_{i=1..n/2} ceiling(floor(2(n-1)/(i^2+i))/(2n)). - José de Jesús Camacho Medina, Jan 07 2017
a(n) = floor((sqrt(8*n-7)+1)/2). - Néstor Jofré, Apr 24 2017
a(n) = floor((A000196(8*n)+1)/2). - Pontus von Brömssen, Dec 10 2018
Sum_{n>=1} (-1)^(n+1)/a(n) = Pi/4 (A003881). - Amiram Eldar, Oct 01 2022
G.f. as array: (x^2*(1 - y)^2 + y^2 + x*y*(1 - 2*y))/((1 - x)^2*(1 - y)^2). - Stefano Spezia, Apr 22 2024

A001462 Golomb's sequence: a(n) is the number of times n occurs, starting with a(1) = 1.

Original entry on oeis.org

1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 19
Offset: 1

Views

Author

Keywords

Comments

It is understood that a(n) is taken to be the smallest number >= a(n-1) which is compatible with the description.
In other words, this is the lexicographically earliest nondecreasing sequence of positive numbers which is equal to its RUNS transform. - N. J. A. Sloane, Nov 07 2018
Also called Silverman's sequence.
Vardi gives several identities satisfied by A001463 and this sequence.
We can interpret this sequence as a triangle: start with 1; 2,2; 3,3; and proceed by letting the row sum of row m-1 be the number of elements of row m. The partial sums of the row sums give 1, 5, 11, 38, 272, ... Conjecture: this proceeds as Lionel Levine's sequence A014644. See also A113676. - Floor van Lamoen, Nov 06 2005
A Golomb-type sequence, that is, one with the property of being a sequence of run length of itself, can be built over any sequence with distinct terms by repeating each term a corresponding number of times, in the same manner as a(n) is built over natural numbers. See cross-references for more examples. - Ivan Neretin, Mar 29 2015
From Amiram Eldar, Jun 19 2021: (Start)
Named after the American mathematician Solomon Wolf Golomb (1932-2016).
Guy (2004) called it "Golomb's self-histogramming sequence", while in previous editions of his book (1981 and 1994) he called it "Silverman's sequence" after David Silverman. (End)
a(n) is also the number of numbers that occur n times. - Leo Crabbe, Feb 15 2025

Examples

			a(1) = 1, so 1 only appears once. The next term is therefore 2, which means 2 appears twice and so a(3) is also 2 but a(4) must be 3. And so on.
G.f. = x + 2*x^2 + 2*x^3 + 3*x^4 + 3*x^5 + 4*x^6 + 4*x^7 + 4*x^8 + ... - _Michael Somos_, Nov 07 2018
		

References

  • Graham Everest, Alf van der Poorten, Igor Shparlinski and Thomas Ward, Recurrence Sequences, Amer. Math. Soc., 2003; p. 10.
  • Ronald L. Graham, Donald E. Knuth and Oren Patashnik, Concrete Mathematics. Addison-Wesley, Reading, MA, 1990, p. 66.
  • Richard K. Guy, Unsolved Problems in Number Theory, 3rd Edition, Springer, 2004, Section E25, p. 347-348.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane, Seven Staggering Sequences, in Homage to a Pied Puzzler, E. Pegg Jr., A. H. Schoen and T. Rodgers (editors), A. K. Peters, Wellesley, MA, 2009, pp. 93-110.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A001463 (partial sums) and A262986 (start of first run of length n).
First differences are A088517.
Golomb-type sequences over various substrates (from Glen Whitney, Oct 12 2015):
A000002 and references therein (over periodic sequences),
A109167 (over nonnegative integers),
A080605 (over odd numbers),
A080606 (over even numbers),
A080607 (over multiples of 3),
A169682 (over primes),
A013189 (over squares),
A013322 (over triangular numbers),
A250983 (over integral sums of itself).
Applying "ee Rabot" to this sequence gives A319434.
See also A095114.

Programs

  • Haskell
    a001462 n = a001462_list !! (n-1)
    a001462_list = 1 : 2 : 2 : g 3  where
       g x = (replicate (a001462 x) x) ++ g (x + 1)
    -- Reinhard Zumkeller, Feb 09 2012
    
  • Magma
    [ n eq 1 select 1 else 1+Self(n-Self(Self(n-1))) : n in [1..100] ]; // Sergei Haller (sergei(AT)sergei-haller.de), Dec 21 2006
    
  • Maple
    N:= 10000: A001462[1]:= 1: B[1]:= 1: A001462[2]:= 2:
    for n from 2 while B[n-1] <= N do
      B[n]:= B[n-1] + A001462[n];
      for j from B[n-1]+1 to B[n] do A001462[j]:= n end do
    end do:
    seq(A001462[j],j=1..N); # Robert Israel, Oct 30 2012
  • Mathematica
    a[1] = 1; a[n_] := a[n] = 1 + a[n - a[a[n - 1]]]; Table[ a[n], {n, 84}] (* Robert G. Wilson v, Aug 26 2005 *)
    GolSeq[n_]:=Nest[(k = 0; Flatten[# /. m_Integer :> (ConstantArray[++k,m])]) &, {1, 2}, n]
    GolList=Nest[(k = 0;Flatten[# /.m_Integer :> (ConstantArray[++k,m])]) &, {1, 2},7]; AGolList=Accumulate[GolList]; Golomb[n_]:=Which[ n <= Length[GolList], GolList[[n]], n <= Total[GolList],First[FirstPosition[AGolList, ?(# > n &)]], True, $Failed] (* _JungHwan Min, Nov 29 2015 *)
  • PARI
    a = [1, 2, 2]; for(n=3, 20, for(i=1, a[n], a = concat(a, n))); a /* Michael Somos, Jul 16 1999 */
    
  • PARI
    {a(n) = my(A, t, i); if( n<3, max(0, n), A = vector(n); t = A[i=2] = 2; for(k=3, n, A[k] = A[k-1] + if( t--==0, t = A[i++]; 1)); A[n])}; /* Michael Somos, Oct 21 2006 */
    
  • Python
    a=[0, 1, 2, 2]
    for n in range(3, 21):a+=[n for i in range(1, a[n] + 1)]
    a[1:] # Indranil Ghosh, Jul 05 2017

Formula

a(n) = phi^(2-phi)*n^(phi-1) + E(n), where phi is the golden number (1+sqrt(5))/2 (Marcus and Fine) and E(n) is an error term which Vardi shows is O( n^(phi-1) / log n ).
a(1) = 1; a(n+1) = 1 + a(n+1-a(a(n))). - Colin Mallows
a(1)=1, a(2)=2 and for a(1) + a(2) + ... + a(n-1) < k <= a(1) + a(2) + ... + a(n) we have a(k)=n. - Benoit Cloitre, Oct 07 2003
G.f.: Sum_{n>0} a(n) x^n = Sum_{k>0} x^a(k). - Michael Somos, Oct 21 2006
a(A095114(n)) = n and a(m) < n for m < A095114(n). - Reinhard Zumkeller, Feb 09 2012 [First inequality corrected from a(m) < m by Glen Whitney, Oct 06 2015]
Conjecture: a(n) >= n^(phi-1) for all n. - Jianing Song, Aug 19 2021
a(n) = A095114(n+1) - A095114(n). - Alan Michael Gómez Calderón, Dec 21 2024 after Ralf Stephan

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.

Original entry on oeis.org

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, 99, 102, 106, 114, 126, 131, 138, 145, 148, 155, 175, 177, 180, 182, 189, 197, 206, 209, 219, 221, 236, 238, 241, 243, 253, 258, 260, 273, 282, 309, 316, 319, 324, 339
Offset: 1

Views

Author

Keywords

Comments

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.
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
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
_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).
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.
From Jud McCranie on David W. Wilson's illustration, Jun 20 2008: (Start)
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.
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)
a(50000000) = 675904508. - Jud McCranie, Feb 29 2012
a(100000000) = 1351856726. - Jud McCranie, Jul 31 2012
a(1000000000) = 13517664323. - Jud McCranie, Aug 28 2015
a(28000000000) = 378485625853 - Philip Gibbs & Jud McCranie, Sep 09 2015
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
Named after the Polish-American scientist Stanislaw Ulam (1909-1984). - Amiram Eldar, Jun 08 2021

References

  • Steven R. Finch, Mathematical Constants, Cambridge, 2003, Section 2.16.2.
  • Richard K. Guy, Unsolved Problems in Number Theory, C4.
  • Donald E. Knuth, The Art of Computer Programming, Volume 4A, Section 7.1.3.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, page 116.
  • 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.
  • 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.

Crossrefs

Cf. A002859 (version beginning 1,3), A054540, A003667, A001857, A007300, A117140, A214603.
First differences: A072832, A072540.
Cf. A080287, A080288, A004280 (if distinct removed from definition).
See also the density plots in A080573 and A285884.

Programs

  • Haskell
    a002858 n = a002858_list !! (n-1)
    a002858_list = 1 : 2 : ulam 2 2 a002858_list
    ulam :: Int -> Integer -> [Integer] -> [Integer]
    ulam n u us = u' : ulam (n + 1) u' us where
       u' = f 0 (u+1) us'
       f 2 z _                         = f 0 (z + 1) us'
       f e z (v:vs) | z - v <= v       = if e == 1 then z else f 0 (z + 1) us'
                    | z - v `elem` us' = f (e + 1) z vs
                    | otherwise        = f e z vs
       us' = take n us
    -- Reinhard Zumkeller, Nov 03 2011
    
  • Julia
    function isUlam(u, n, h, i, r)
        h == 2 && return false
        ur = u[r]; ui = u[i]
        ur <= ui && return h == 1
        if ur + ui > n
            r -= 1
        elseif ur + ui < n
            i += 1
        else
            h += 1; i += 1; r -= 1
        end
        isUlam(u, n, h, i, r)
    end
    function UlamList(len)
        u = Array{Int, 1}(undef, len)
        u[1] = 1; u[2] = 2; i = 2; n = 2
        while i < len
            n += 1
            if isUlam(u, n, 0, 1, i)
                i += 1
                u[i] = n
            end
        end
        return u
    end
    println(UlamList(59)) # Peter Luschny, Apr 07 2019
    
  • Maple
    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:
    UlamList(59); # Peter Luschny, Apr 05 2019
  • Mathematica
    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]
    (* Second program: *)
    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 *)
    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 *)
  • 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
  • Python
    def isUlam(n, h, u, r):
        if h == 2: return False
        hu = u[0]; hr = r[0]
        if hr <= hu: return h == 1
        if hr + hu > n: r = r[1:]
        elif hr + hu < n: u = u[1:]
        else: h += 1; r = r[1:]; u = u[1:]
        return isUlam(n, h, u, r)
    def UlamList(length):
        u = [1, 2]; r = [2, 1]; n = 2
        while len(u) < length:
            n += 1
            if isUlam(n, 0, u[:], r[:]):
                u.append(n); r.insert(0, n)
        return u
    print(UlamList(59)) # Peter Luschny, Apr 06 2019
    

Extensions

More terms from Jud McCranie
Showing 1-10 of 60 results. Next