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-8 of 8 results.

A135491 Number of ways to toss a coin n times and not get a run of four.

Original entry on oeis.org

1, 2, 4, 8, 14, 26, 48, 88, 162, 298, 548, 1008, 1854, 3410, 6272, 11536, 21218, 39026, 71780, 132024, 242830, 446634, 821488, 1510952, 2779074, 5111514, 9401540, 17292128, 31805182, 58498850, 107596160, 197900192, 363995202, 669491554, 1231386948, 2264873704
Offset: 0

Views

Author

James R FitzSimons (cherry(AT)getnet.net), Feb 07 2008

Keywords

Crossrefs

Cf. A000073. Column 2 of A265624. Cf. A135492, A135493, A000213, A058265.

Programs

Formula

a(n) = 2*A000073(n+2) for n > 0.
a(n) = a(n-1) + a(n-2) + a(n-3) for n > 3.
G.f.: -(x+1)*(x^2+1)/(x^3+x^2+x-1).
a(n) = nearest integer to b*c^n, where b = 1.2368... and c = 1.839286755... is the real root of x^3-x^2-x-1 = 0. See A058265. - N. J. A. Sloane, Jan 06 2010
G.f.: (1-x^4)/(1-2*x+x^4) and generally to "not get a run of k" (1-x^k)/(1-2*x+x^k). - Geoffrey Critzer, Feb 01 2012
G.f.: Q(0)/x^2 - 2/x- 1/x^2, where Q(k) = 1 + (1+x)*x^2 + (2*k+3)*x - x*(2*k+1 +x+x^2)/Q(k+1); (continued fraction). - Sergei N. Gladkovskii, Oct 04 2013
a(n) = A000213(n+3) - A000213(n+2), n>=1. - Peter M. Chema, Jan 11 2017.

Extensions

More terms from Robert G. Wilson v, Feb 10 2008
a(0)=1 prepended by Alois P. Heinz, Dec 10 2015

A246892 T(n,k)=Number of length n+4 0..k arrays with some pair in every consecutive five terms totalling exactly k.

Original entry on oeis.org

30, 231, 58, 900, 673, 112, 2701, 3364, 1961, 216, 6210, 12481, 12544, 5711, 416, 12931, 33294, 57585, 46656, 16621, 802, 23400, 79345, 177648, 264981, 173056, 48393, 1546, 40281, 159688, 484297, 942216, 1216081, 643204, 140893, 2980, 63750
Offset: 1

Views

Author

R. H. Hardin, Sep 06 2014

Keywords

Comments

Table starts
....30.....231.......900.......2701........6210........12931........23400
....58.....673......3364......12481.......33294........79345.......159688
...112....1961.....12544......57585......177648.......484297......1079680
...216....5711.....46656.....264981......942216......2934691......7216512
...416...16621....173056....1216081.....4971120.....17677453.....47799488
...802...48393....643204....5592169....26346486....107053441....319477960
..1546..140893...2390116...25710385...139555230....647845357...2132283592
..2980..410197...8880400..118192273...738947844...3918872917..14219886016
..5744.1194243..32993536..543322645..3912529200..23704560247..94826520320
.11072.3476929.122589184.2497751105.20719113168.143411404177.632600369216

Examples

			Some solutions for n=3 k=4
..0....0....2....0....2....3....4....3....1....2....3....1....4....4....3....4
..3....4....0....1....3....0....2....2....1....0....3....1....1....1....0....1
..0....0....1....0....4....0....1....3....1....3....0....2....3....0....4....4
..2....4....2....3....0....4....3....4....2....0....1....4....0....2....2....3
..1....1....0....1....1....4....1....2....3....2....2....3....2....2....1....1
..4....0....2....1....1....4....2....1....1....4....2....2....1....2....0....2
..4....1....2....2....4....3....0....3....2....1....3....4....3....1....2....2
		

Crossrefs

Column 1 is A135492(n+4)

Formula

Empirical for column k:
k=1: a(n) = a(n-1) +a(n-2) +a(n-3) +a(n-4)
k=2: [order 14]
k=3: [order 10]
k=4: [order 31]
k=5: [order 14]
k=6: [order 39]
k=7: [order 15]
k=8: [order 40]
k=9: [order 15]
Empirical for row n:
n=1: a(n) = 2*a(n-1) +2*a(n-2) -6*a(n-3) +6*a(n-5) -2*a(n-6) -2*a(n-7) +a(n-8)
n=2: [order 10]
n=3: [order 12]
n=4: [order 13]
n=5: [order 14]
n=6: [order 16]
n=7: [order 18]

A249001 T(n,k)=Number of length n+4 0..k arrays with no five consecutive terms having two times the sum of any three elements equal to three times the sum of the remaining two.

Original entry on oeis.org

30, 190, 58, 820, 464, 112, 2540, 2668, 1140, 216, 6450, 10360, 8680, 2802, 416, 13990, 32398, 42308, 28240, 6872, 802, 27740, 82348, 163112, 172888, 91888, 16800, 1546, 50260, 189660, 485580, 822348, 706704, 299044, 41084, 2980, 86030, 387900
Offset: 1

Views

Author

R. H. Hardin, Oct 18 2014

Keywords

Comments

Table starts
....30....190......820......2540........6450........13990........27740
....58....464.....2668.....10360.......32398........82348.......189660
...112...1140.....8680.....42308......163112.......485580......1298968
...216...2802....28240....172888......822348......2865126......8902860
...416...6872....91888....706704.....4149708.....16909524.....61034658
...802..16800...299044...2888944....20952218.....99817384....418454994
..1546..41084...973204..11810564...105819690....589354152...2869206494
..2980.100590..3167500..48286456...534502810...3479916010..19673497892
..5744.246378.10309372.197422012..2700047696..20548067494.134897701458
.11072.603406.33554728.807188768.13640156760.121333048614.924972633722

Examples

			Some solutions for n=4 k=4
..2....0....1....0....1....0....0....1....0....2....0....0....1....1....1....2
..1....0....1....2....0....2....3....0....4....3....2....4....1....3....0....1
..2....3....1....2....2....2....1....3....0....1....1....4....0....3....0....0
..2....0....3....2....0....2....3....2....1....4....3....2....2....1....1....4
..1....1....3....0....0....2....0....0....4....2....3....3....2....4....0....0
..3....4....0....2....0....4....0....2....0....2....4....4....3....0....1....0
..0....1....2....0....4....3....2....2....3....4....2....0....0....0....1....2
..1....2....0....4....0....3....4....0....1....4....1....2....0....3....0....0
		

Crossrefs

Column 1 is A135492(n+4)

Formula

Empirical for column k:
k=1: a(n) = a(n-1) +a(n-2) +a(n-3) +a(n-4)
k=2: [order 37]
k=3: [order 9]
Empirical for row n:
n=1: [linear recurrence of order 13; also a polynomial of degree 5 plus a quadratic quasipolynomial with period 6]

A249466 T(n,k)=Number of length n+4 0..k arrays with no five consecutive terms having four times any element equal to the sum of the remaining four.

Original entry on oeis.org

30, 190, 58, 860, 464, 112, 2640, 2948, 1140, 216, 6730, 11260, 10124, 2802, 416, 14730, 35322, 48180, 34832, 6872, 802, 29060, 91160, 185982, 206428, 119932, 16800, 1546, 52900, 207760, 565516, 980718, 884728, 412972, 41084, 2980, 90390, 429364
Offset: 1

Views

Author

R. H. Hardin, Oct 29 2014

Keywords

Comments

Table starts
....30....190......860.......2640........6730........14730.........29060
....58....464.....2948......11260.......35322........91160........207760
...112...1140....10124......48180......185982.......565516.......1488294
...216...2802....34832.....206428......980718......3512232......10671554
...416...6872...119932.....884728.....5174842.....21824440......76550058
...802..16800...412972....3791504....27309702....135637752.....549183692
..1546..41084..1422232...16249428...144140836....843025344....3940066010
..2980.100590..4898776...69646680...760833398...5239822940...28268238072
..5744.246378.16874830..298527530..4016197550..32568952752..202814997034
.11072.603406.58131580.1279613894.21200828116.202440565098.1455140474848

Examples

			Some solutions for n=3 k=4
..0....2....0....1....2....3....2....3....3....3....4....3....4....4....2....3
..0....0....1....0....0....0....4....0....0....4....3....4....3....2....4....2
..2....0....2....2....1....4....3....0....0....4....4....0....2....0....1....2
..3....0....3....0....1....0....2....4....3....3....1....3....3....0....4....0
..3....2....0....3....2....3....0....0....4....4....2....4....0....2....1....1
..3....2....0....1....0....4....0....3....2....3....4....2....0....2....3....2
..3....4....0....2....3....1....4....2....3....3....0....4....2....4....2....1
		

Crossrefs

Column 1 is A135492(n+4)
Column 2 is A248995

Formula

Empirical for column k:
k=1: a(n) = a(n-1) +a(n-2) +a(n-3) +a(n-4)
k=2: [order 37]
Empirical for row n:
n=1: [linear recurrence of order 11; also a polynomial of degree 5 plus a constant quasipolynomial with period 12]

A135493 Number of ways to toss a coin n times and not get a run of six.

Original entry on oeis.org

1, 2, 4, 8, 16, 32, 62, 122, 240, 472, 928, 1824, 3586, 7050, 13860, 27248, 53568, 105312, 207038, 407026, 800192, 1573136, 3092704, 6080096, 11953154, 23499282, 46198372, 90823608, 178554512, 351028928, 690104702, 1356710122, 2667221872
Offset: 0

Views

Author

James R FitzSimons (cherry(AT)getnet.net), Feb 07 2008

Keywords

Crossrefs

Programs

  • Mathematica
    a[n_] := a[n] = a[n - 1] + a[n - 2] + a[n - 3] + a[n - 4] + a[n - 5]; a[1] = 2; a[2] = 4; a[3] = 8; a[4] = 16; a[5] = 32; Array[a, 33] (* Robert G. Wilson v, Feb 10 2008 *)
    LinearRecurrence[{1, 1, 1, 1, 1}, {2, 4, 8, 16, 32}, 25] (* G. C. Greubel, Oct 15 2016 *)

Formula

a(n) = a(n-1) + a(n-2) + a(n-3) + a(n-4) + a(n-5).
From R. J. Mathar, Feb 10 2008: (Start)
O.g.f.: -1 - 2/(-1+x+x^2+x^3+x^4+x^5).
a(n) = 2*A001591(n+4) for n>=1. (End)

Extensions

More terms from Robert G. Wilson v, Feb 10 2008
a(0)=1 prepended by Alois P. Heinz, May 22 2025

A181137 The number of ways to color n balls in a row with 3 colors with no color runs having lengths greater than 3.

Original entry on oeis.org

1, 3, 9, 27, 78, 228, 666, 1944, 5676, 16572, 48384, 141264, 412440, 1204176, 3515760, 10264752, 29969376, 87499776, 255467808, 745873920, 2177683008, 6358049472, 18563212800, 54197890560, 158238305664, 461998818048, 1348870028544, 3938214304512
Offset: 0

Views

Author

William Sit (wyscc(AT)sci.ccny.cuny.edu), Oct 06 2010

Keywords

Comments

This sequence is a special case of the general problem for coloring n balls in a row with p colors where each color has a given maximum run-length. In this example, the bounds are uniformly 3. It can be phrased in terms of tossing a p-faced die n times, requiring each face to have no runs longer than b.
Generating function and recurrence for given p and uniform bound b are known. a(n+b) = (p-1)(a(n)+ ... + a(n+b-1)), using b initial values a(1)=p, a(2)=p^2, ..., a(b)=p^(b) The g.f. is p*G/(1-(p-1)*G) where G = t + t^2 + ... + t^b.

Examples

			For p=3 and b=3, a(4)=78. The colorings are: 1112, 1113, 1121, 1122, 1123, 1131, 1132, 1133, 1211, 1212, 1213, 1221, 1222, 1223, 1231, 1232, 1233, 1311, 1312, 1313, 1321, 1322, 1323, 1331, 1332, 1333, 2111, 2112, 2113, 2121, 2122, 2123, 2131, 2132, 2133, 2211, 2212, 2213, 2221, 2223, 2231, 2232, 2233, 2311, 2312, 2313, 2321, 2322, 2323, 2331, 2332, 2333, 3111, 3112, 3113, 3121, 3122, 3123, 3131, 3132, 3133, 3211, 3212, 3213, 3221, 3222, 3223, 3231, 3232, 3233, 3311, 3312, 3313, 3321, 3322, 3323, 3331, 3332.
		

Crossrefs

A135492 is sequence[2, {2, 4, 6, 8}, n-4], for colorings of n balls in a row with p=2 colors so no color has run length more than 4. A135491 coloring of 2 balls in a row with p=2 colors so no color has run length more than 3. In general 2 colorings are like coin tossing. The example here is 3 colorings (tossing 3-sided dice).
Column 3 in A265624.

Programs

  • Mathematica
    (* next[p,z] computes the next member in a sequence and
    next[p,z] = a(n+b)= (p-1)( c(b)+ ... + c(n+b-1)) where z is the preceding b items on the sequence starting with a(n) where b is the uniform bound on runs.
    The function sequence[p,z,n] computes the next n terms. *) next[p_,z_]:=(p-1) Apply[Plus,z] sequence[p_,z_,n_]:=Module[{y=z,seq=z, m=n, b=Length[z]}, While[m>0, seq = Join[seq,{next[p,y]}]; y = Take[seq, -b]; m-- ]; seq] (* sequence[3,{3,9,27},10] computes the next 10 terms after 3,9,27. *)
    LinearRecurrence[{2,2,2},{1,3,9,27},30] (* Harvey P. Dale, Dec 01 2017 *)
  • PARI
    Vec((1 + x)*(1 + x^2) / (1 - 2*x - 2*x^2 - 2*x^3) + O(x^30)) \\ Colin Barker, Jun 28 2019

Formula

G.f.: 1+3t(t^2+t+1)/(1 - 2t(t^2+t+1)).
a(n+3) = 2(a(n)+a(n+1)+a(n+2)), a(0)=1, a(1)=3, a(2)=9, a(3)=27.
a(n) = 3*A119826(n-1). - R. J. Mathar, Dec 10 2015
G.f.: (1 + x)*(1 + x^2) / (1 - 2*x - 2*x^2 - 2*x^3). - Colin Barker, Jun 28 2019

Extensions

a(0)=1 prepended by Alois P. Heinz, Dec 10 2015

A181140 The number of ways to color n balls in a row with 3 colors with no color runs having lengths greater than 4. This sequence is a special case of the general problem for coloring n balls in a row with p colors where each color has a given maximum run-length. In this example, the bounds are uniformly 4. It can be phrased in terms of tossing a p-faced die n times, requiring each face to have no runs longer than b.

Original entry on oeis.org

3, 9, 27, 81, 240, 714, 2124, 6318, 18792, 55896, 166260, 494532, 1470960, 4375296, 13014096, 38709768, 115140240, 342478800, 1018685808, 3030029232, 9012668160, 26807724000, 79738214400, 237177271584, 705471756288, 2098389932544
Offset: 1

Views

Author

William Sit (wyscc(AT)sci.ccny.cuny.edu), Oct 06 2010

Keywords

Comments

Generating function and recurrence for given p and uniform bound b are known.
a(n+b) = (p-1)(a(n) + ... + a(n+b-1)),
using b initial values a(1)=p, a(2)=p^2, ..., a(b)=p^(b).
The g.f. is p G/(1-(p-1)G) where G = t + t^2 + ... + t^b.

Examples

			The first nontrivial value is a(5)=240. These solutions are listed below: 11112,11113,11121,11122,11123,
11131,11132,11133,11211,11212,11213,11221,11222,11223,11231,11232,11233,11311,11312,11313,11321,11322,11323,
11331,11332,11333,12111,12112,12113,12121,12122,12123,12131,12132,12133,12211,12212,12213,12221,12222,12223,
12231,12232,12233,12311,12312,12313,12321,12322,12323,12331,12332,12333,13111,13112,13113,13121,13122,13123,
13131,13132,13133,13211,13212,13213,13221,13222,13223,13231,
13232,13233,13311,13312,13313,13321,13322,13323,13331,13332,13333,21111,21112,21113,21121,21122,21123,21131,
21132,21133,21211,21212,21213,21221,21222,21223,21231,21232,21233,21311,21312,21313,21321,21322,21323,21331,
21332,21333,22111,22112,22113,22121,22122,22123,22131,22132,22133,22211,22212,22213,22221,22223,22231,22232,
22233,22311,22312,22313,22321,22322,22323,22331,22332,22333,23111,23112,23113,23121,23122,23123,23131,23132,
23133,23211,23212,23213,23221,23222,23223,23231,23232,23233,23311,
23312,23313,23321,23322,23323,23331,23332,23333,31111,31112,31113,31121,31122,31123,31131,31132,31133,31211,
31212,31213,31221,31222,31223,31231,31232,31233,31311,31312,31313,31321,31322,31323,31331,31332,31333,32111,
32112,32113,32121,32122,32123,32131,32132,32133,32211,32212,32213,32221,32222,32223,32231,32232,32233,32311,
32312,32313,32321,32322,32323,32331,32332,32333,33111,33112,33113,33121,33122,33123,33131,33132,33133,33211,
33212,33213,33221,33222,33223,33231,33232,33233,33311,33312,33313,33321,33322,33323,33331,33332
		

Crossrefs

Programs

  • Mathematica
    (* next[p,z] computes the next member in a sequence and next[p,z] = a(n+b)= (p-1)( c(b)+ ... + c(n+b-1))
    where z is the preceding b items on the sequence starting with a(n) where b is the uniform bound on runs.
    The function sequence[p,z,n] computes the next n terms. *)
    next[p_,z_]:=(p-1) Apply[Plus,z]
    sequence[p_,z_,n_]:=Module[{y=z,seq=z, m=n, b=Length[z]}, While[m>0, seq = Join[seq,{next[p,y]}]; y = Take[seq, -b]; m-- ]; seq]
    (* sequence[3,{3,9,27,81},10] computes the next 10 terms after 3,9,27, 81. *)

Formula

For this sequence (p=3, b=4):
G.f.: 3t(t^3+t^2+t+1)/(1 - 2t(t^3+t^2+t+1));
a(n+4) = 2(a(n)+a(n+1)+a(n+2)+a(n+3)); a(1)=3, a(2)=9, a(3)=27, a(4)=81.

A277828 Least number of tosses of a fair coin needed to have an even chance or better of getting a run of at least m consecutive heads or consecutive tails.

Original entry on oeis.org

1, 2, 5, 11, 23, 45, 90, 179, 357, 712, 1422, 2842, 5681, 11360, 22716, 45430, 90856, 181709, 363413, 726822, 1453640, 2907276, 5814546, 11629086, 23258166, 46516327, 93032647
Offset: 1

Views

Author

Tim Miles, Nov 01 2016

Keywords

Comments

There are a family of sequences that represent the number of sequences of tosses of a fair coin to n tosses where there are no runs of m or more consecutive heads or consecutive tails. Some are given in this Encyclopedia. Their general form is given as part of the formula below. As n increases, the proportion of sequences of tosses that meet this condition decreases. When that proportion becomes a half or less of the total number of sequences of tosses, there is an even or better chance that a run of m consecutive heads or m consecutive tails occurs.
There is actually a family of sequences of which the above sequence is an instance: those in which, for successive values of m, r*g(n) <= 2^n for r > 1.
a(n) - ceiling((log 2)*2^n + (1-log 2)*n + (log 2)/2-2) equals 0 or (almost never) 1 for all n. Obtained using Weisstein's exact formula for Fibonacci k-step number seeing that the function g(N) described in the Formula section is 2*A092921(n-1,N+1). - Andrey Zabolotskiy, Nov 01 2016

References

  • Marcus du Sautoy, The Number Mysteries, Fourth Estate, 2011, pages 126 - 127.

Crossrefs

Programs

  • Maple
    a:= proc(n) option remember; local l, j; Digits:= 50;
          if n<3 then n else l:= 0$n;
            for j from 0 while l[n]<1/2 do l:= seq(
              (`if`(i=1, 1.0, l[i-1])+l[n-1])/2, i=1..n)
            od; j
          fi
        end:
    seq(a(n), n=1..16);  # Alois P. Heinz, Nov 01 2016
  • Mathematica
    a[n_] := a[n] = Module[{l, j}, If[n < 3, n, l = Table[0, {n}]; For[j = 0, l[[n]] < 1/2, j++, l = Table[(If[i == 1, 1, l[[i - 1]]] + l[[n - 1]])/2, {i, n}]]; j]];
    Array[a, 16] (* Jean-François Alcover, May 31 2019, after Alois P. Heinz *)
  • PARI
    step(v)=my(n=#v); concat([sum(i=1,n-1,v[i])], concat(vector(n-2,i, v[i]), 2*v[n]+v[n-1]))
    a(n)=if(n<3, return(n)); my(v=vector(n), flips=1, needed=1/2); v[1]=1; while(v[n]Charles R Greathouse IV, Nov 02 2016
    
  • PARI
    a(n)=if(n<3, return(n)); my(M=2^(n-1),v=powers(2,n-1)[2..n],i=1,m=n); while(1, v[i]=vecsum(v); if(v[i]<=M, return(m)); if(i++>#v, i=1); M*=2; m++) \\ Charles R Greathouse IV, Nov 02 2016
  • Python
    def a(m):
        if m == 1:
            return 1
        g = [2**i for i in range(1, m)]
        sg, lim, n = sum(g), 2**(m-1), m
        while True:
            g.append(sg)
            sg <<= 1
            sg -= g.pop(0)
            if g[-1] <= lim:
                return n
            lim <<= 1
            n += 1
    print([a(i) for i in range(1, 15)])
    # Andrey Zabolotskiy, Nov 01 2016
    

Formula

For successive integers m, where g(n) is the number of sequences of tosses of a fair coin with runs of fewer than m consecutive heads or tails out of all possible sequences of tosses to n tosses, g(n) = 2^n where n <= m-1, and thereafter g(n) = g(n-1) + g(n-2) + ... + g(n-m+1) and a(m) = the least value of n for which 2g(n) <= 2^n.

Extensions

a(11)-a(22) from Andrey Zabolotskiy, Nov 01 2016
a(23)-a(27) from Alois P. Heinz, Nov 02 2016
Showing 1-8 of 8 results.