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.

User: Stéphane Legendre

Stéphane Legendre's wiki page.

Stéphane Legendre has authored 8 sequences.

A235757 Ruler function associated with the set of permutations generated by cyclic shift in cyclic order, array read by rows.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 4
Offset: 2

Author

Stéphane Legendre, Jan 15 2014

Keywords

Comments

Variant of A235748.
The set of permutations S_n = {p_0, ..., p_{n!-1}} is ordered according to generation by cyclic shift. The order is considered cyclic, i.e., p_0 is next to p_{n!-1}.
Row n, denoted F(n), has n! (A000142) entries.
F(2) = 1 1
F(3) = 1 1 2 1 1 2
F(4) = 1 1 1 2 1 1 1 2 1 1 1 3 1 1 1 2 1 1 1 2 1 1 1 3
F(5) = 111121111211112111131111211112111121111311112111121111211114...4
The term of index k (k = 0, ..., n!-1) of row n is the number of symbols that have to be erased to the left of a permutation p_k so that the last symbols of the permutation match the first symbols of the next permutation p_{k+1}. The terms of F(n) sum to 1! + 2! + ... + n! - 1.

Examples

			S_2 = {12,21}.
S_3 = {123,231,312,213,132,321}, generated by cyclic shift from S_2.
The ruler sequence is F(6) = 1 1 2 1 1 2. For example, 2 terms need to be erased to the left of p_6 = 321 to match the first symbols of p_0 = 123.
		

References

  • D. E. Knuth, The Art of Computer Programming, Vol. 4, Combinatorial Algorithms, 7.2.1.2, Addison-Wesley, 2005.

Programs

  • Mathematica
    a[nmax_] := Module[{n,b={},w,f,g,i,k},
    Do[w = {};f = n!-1;Do[w = Append[w,1],{i,1,f}];
       g = 1;
       Do[g = g*k;
          Do[If[Mod[i,g] == 0,w[[i]] = w[[i]]+1],{i,1,f}],
          {k,n,2,-1}];
       w = Append[w,n-1];
       b = Join[b,w],
       {n,2,nmax}];
    b]
    (* or: *) row[2] = {1, 1}; row[n_] := row[n] = Riffle[Table[Array[1&, n-1], {Length[row[n-1]]}], row[n-1]+1] // Flatten; row /@ Range[2, 5] // Flatten (* Jean-François Alcover, Jan 16 2014 *)

Formula

F(n) := if n = 2 then 11 else
(a) Set F'(n-1) equal to F(n-1) with all entries incremented by 1;
(b) Insert a run of n-1 ones between all entries of F'(n-1) and at the beginning.
Sequence a = F(2)F(3)...

A235748 Ruler function associated with the set of permutations generated by cyclic shift, array read by rows.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 4
Offset: 2

Author

Stéphane Legendre, Jan 15 2014

Keywords

Comments

The sequence is to permutations what the ruler function (A001511) is to binary numbers.
Row n is the ruler sequence E(n) associated with the set of permutations S_n, n >= 2.
E(n) has n!-1 (A033312) entries.
E(2) = 1
E(3) = 1 1 2 1 1
E(4) = 1 1 1 2 1 1 1 2 1 1 1 3 1 1 1 2 1 1 1 2 1 1 1
E(5) = 111121111211112111131111211112111121111311112111121111211114...
When S_n = {p_0, ..., p_{n!-1}} is ordered according to generation by cyclic shift, the term of index k (k = 0, ..., n!-2) of row n is the number of symbols that have to be erased to the left of a permutation p_k so that the last symbols of the permutation match the first symbols of the next permutation p_{k+1}.
E(n) is a palindrome, its terms sum to 1! + 2! + ... + n! - n, and any integer 1 <= i <= n-1 appears (n - i)(n - i)! times.

Examples

			S_2 = {12,21}.
S_3 = {123,231,312,213,132,321}, generated by cyclic shift from S_2.
The ruler sequence is E(3) = 1 1 2 1 1. For example, 2 terms need to be erased to the left of p_2 = 312 to match the first symbols of p_3 = 213.
		

References

  • D. E. Knuth, The Art of Computer Programming, Vol. 4, Combinatorial Algorithms, 7.2.1.2, Addison-Wesley, 2005.

Programs

  • Mathematica
    a[nmax_] :=
    Module[{n, b = {}, w, f, g, i, k},
      Do[w = {}; f = n! - 1; Do[w = Append[w, 1], {i, 1, f}];
       g = 1;
       Do[g = g*k;
        Do[If[Mod[i, g] == 0, w[[i]] = w[[i]] + 1], {i, 1, f}], {k, n,
         2, -1}];
       b = Join[b, w], {n, 2, nmax}];
      b]
    (* A non-procedural variant: *) row[2] = {1}; row[n_] := row[n] = Riffle[Table[Array[1&, n-1], {Length[row[n-1]]+1}], row[n-1]+1] // Flatten; row /@ Range[2, 5] // Flatten (* Jean-François Alcover, Jan 16 2014 *)

Formula

E(n) := if n = 2 then 1 else
(a) Set E'(n-1) equal to E(n-1) with all entries incremented by 1;
(b) Insert a run of n-1 ones between all entries of E'(n-1) and at both extremities.
Sequence a = E(2)E(3)...

A159065 Number of crossings in a regular drawing of the complete bipartite graph K(n,n).

Original entry on oeis.org

0, 1, 7, 27, 65, 147, 261, 461, 737, 1143, 1637, 2349, 3217, 4401, 5769, 7457, 9433, 11945, 14753, 18235, 22173, 26771, 31801, 37813, 44449, 52161, 60489, 69955, 80289, 92203, 104941, 119493, 135261, 152705, 171205, 191649, 213473, 237877
Offset: 1

Author

Stéphane Legendre, Apr 04 2009, Jul 11 2009

Keywords

Examples

			For n = 3 draw vertically 3 points regularly spaced on the right, and 3 points regularly spaced on the left. Join the left and right points by straight lines. These lines cross at c(3) = 7 points.
		

References

  • Umberto Eco, Foucault's Pendulum. San Diego: Harcourt Brace Jovanovich, p. 473, 1989.
  • Athanasius Kircher (1601-1680). Ars Magna Sciendi, In XII Libros Digesta, qua nova et universali Methodo Per Artificiosum Combinationum contextum de omni re proposita plurimis et prope infinitis rationibus disputari, omniumque summaria quaedam cognitio comparari potest, Amstelodami, Apud Joannem Janssonium a Waesberge, et Viduam Elizei Weyerstraet, 1669, fol., pp. 482 (altra ed.: Amstelodami.(ut supra), 1671).

Crossrefs

Programs

  • Maple
    A159065 := proc(n)
        local a,b,c ;
        c := 0 ;
        for a from 1 to n-1 do
        for b from 1 to n-1 do
            if igcd(a,b) = 1 then
                c := c+(n-a)*(n-b) ;
                if 2*a< n and 2*b < n then
                    c := c-(n-2*a)*(n-2*b) ;
                end if;
            end if;
        end do:
        end do:
        c ;
    end proc:
    seq(A159065(n),n=1..30); # R. J. Mathar, Jul 20 2017
  • Mathematica
    a[n_] := Module[{x, y, s1 = 0, s2 = 0}, For[x = 1, x <= n-1, x++, For[y = 1, y <= n-1, y++, If[GCD[x, y] == 1, s1 += (n-x)*(n-y); If[2*x <= n-1 && 2*y <= n-1, s2 += (n-2*x)*(n-2*y)]]]]; s1-s2]; Table[a[n], {n, 1, 40}] (* Jean-François Alcover, Jan 10 2014, translated from Joerg Arndt's PARI code *)
  • PARI
    a(n) = {
        my(s1=0, s2=0);
        for (x=1, n-1,
            for (y=1, n-1,
                if ( gcd(x, y)==1,
                    s1 += (n-x) * (n-y);
                    if ( ( 2*x<=n-1) && (2*y<=n-1),
                        s2 += (n-2*x) * (n-2*y); );
                 );
            );
        );
        return( s1 - s2 );
    }
    \\ Joerg Arndt, Oct 13 2013
    
  • Pascal
    s1:=0; s2:=0;
    for a:=1 to n-1 do
       for b:=1 to n-1 do
          if gcd(a, b)=1 then
          begin
             s1:=s1+(n-a)*(n-b);
             if (2*a<=n-1) and (2*b<=n-1) then
                s2:=s2+(n-2*a)*(n-2*b);
          end;
    a:=s1-s2;
    
  • Python
    from math import gcd
    def a159065(n):
        c=0
        for a in range(1, n):
            for b in range(1, n):
                if gcd(a, b)==1:
                    c+=(n - a)*(n - b)
                    if 2*aIndranil Ghosh, Jul 20 2017
    
  • Python
    from sympy import totient
    def A159065(n): return n-1 if n <= 2 else 2*n-3+3*sum(totient(i)*(n-i)*i for i in range(2,(n+1)//2)) + sum(totient(i)*(n-i)*(2*n-i) for i in range((n+1)//2,n)) # Chai Wah Wu, Aug 16 2021

Formula

a(n) = Sum((n-a)*(n-b); 1<=a
a(n) = (9/(8*Pi^2))*n^4 + O(n^3 log(n)). Asymptotic to (9/(2*Pi^2))*A000537(n-1).
For n > 2: a(n) = A115004(n-1)-(n-2)^2-2*Sum{n=2..floor((n-1)/2)} (n-2i)*(n-i)*phi(i) = 2n-3+3*Sum{n=2..floor((n-1)/2)}(n-i)*i*phi(i) + Sum_{n=floor((n+1)/2)..n-1} (n-i)*(2n-i)*phi(i). - Chai Wah Wu, Aug 16 2021

A007822 Number of symmetric foldings of 2n+1 stamps.

Original entry on oeis.org

1, 1, 3, 9, 28, 89, 287, 935, 3072, 10157, 33767, 112736, 377836, 1270203, 4282311, 14470629, 49005732, 166261653, 565055147, 1923186472, 6554868916, 22367933148, 76417819396, 261335128098, 894597454360, 3064970675173
Offset: 1

Keywords

Crossrefs

Cf. A001010.

Extensions

More terms from Stéphane Legendre (2013) added by N. J. A. Sloane, Mar 30 2013

A005316 Meandric numbers: number of ways a river can cross a road n times.

Original entry on oeis.org

1, 1, 1, 2, 3, 8, 14, 42, 81, 262, 538, 1828, 3926, 13820, 30694, 110954, 252939, 933458, 2172830, 8152860, 19304190, 73424650, 176343390, 678390116, 1649008456, 6405031050, 15730575554, 61606881612, 152663683494, 602188541928, 1503962954930, 5969806669034, 15012865733351, 59923200729046, 151622652413194, 608188709574124, 1547365078534578, 6234277838531806, 15939972379349178, 64477712119584604, 165597452660771610, 672265814872772972, 1733609081727968492, 7060941974458061392
Offset: 0

Keywords

Comments

Number of ways that a river (or directed line) that starts in the southwest and flows east can cross an east-west road n times (see the illustration).
Or, number of ways that an undirected line can cross a road with at least one end below the road.

References

  • Alon, Noga and Maass, Wolfgang, Meanders and their applications in lower bounds arguments. Twenty-Seventh Annual IEEE Symposium on the Foundations of Computer Science (Toronto, ON, 1986). J. Comput. System Sci. 37 (1988), no. 2, 118-129.
  • V. I. Arnol'd, A branched covering of CP^2->S^4, hyperbolicity and projective topology [ Russian ], Sibir. Mat. Zhurn., 29 (No. 2, 1988), 36-47 = Siberian Math. J., 29 (1988), 717-725.
  • V. I. Arnol'd, ed., Arnold's Problems, Springer, 2005; Problem 1989-18.
  • B. Bobier and J. Sawada, A fast algorithm to generate open meandric systems and meanders, ACM Transactions on Algorithms, Vol. 6, No. 2, 2010, article #42.
  • Di Francesco, P. The meander determinant and its generalizations. Calogero-Moser-Sutherland models (Montreal, QC, 1997), 127-144, CRM Ser. Math. Phys., Springer, New York, 2000.
  • Di Francesco, P., SU(N) meander determinants. J. Math. Phys. 38 (1997), no. 11, 5905-5943.
  • Di Francesco, P. Truncated meanders. Recent developments in quantum affine algebras and related topics (Raleigh, NC, 1998), 135-162, Contemp. Math., 248, Amer. Math. Soc., Providence, RI, 1999.
  • Di Francesco, P. Meander determinants. Comm. Math. Phys. 191 (1998), no. 3, 543-583.
  • Di Francesco, P. Exact asymptotics of meander numbers. Formal power series and algebraic combinatorics (Moscow, 2000), 3-14, Springer, Berlin, 2000.
  • Di Francesco, P., Golinelli, O. and Guitter, E., Meanders. In The Mathematical Beauty of Physics (Saclay, 1996), pp. 12-50, Adv. Ser. Math. Phys., 24, World Sci. Publishing, River Edge, NJ, 1997.
  • Di Francesco, P., Golinelli, O. and Guitter, E. Meanders and the Temperley-Lieb algebra. Comm. Math. Phys. 186 (1997), no. 1, 1-59.
  • Di Francesco, P., Guitter, E. and Jacobsen, J. L. Exact meander asymptotics: a numerical check. Nuclear Phys. B 580 (2000), no. 3, 757-795.
  • Franz, Reinhard O. W. A partial order for the set of meanders. Ann. Comb. 2 (1998), no. 1, 7-18.
  • Franz, Reinhard O. W. and Earnshaw, Berton A. A constructive enumeration of meanders. Ann. Comb. 6 (2002), no. 1, 7-17.
  • Isakov, N. M. and Yarmolenko, V. I. Bounded meander approximations. (Russian) Qualitative and approximate methods for the investigation of operator equations (Russian), 71-76, 162, Yaroslav. Gos. Univ., 1981.
  • Lando, S. K. and Zvonkin, A. K. Plane and projective meanders. Conference on Formal Power Series and Algebraic Combinatorics (Bordeaux, 1991).
  • Lando, S. K. and Zvonkin, A. K. Meanders. In Selected translations. Selecta Math. Soviet. 11 (1992), no. 2, 117-144.
  • Makeenko, Y., Strings, matrix models and meanders. Theory of elementary particles (Buckow, 1995). Nuclear Phys. B Proc. Suppl. 49 (1996), 226-237.
  • A. Panayotopoulos, On Meandric Colliers, Mathematics in Computer Science, (2018). https://doi.org/10.1007/s11786-018-0389-6.
  • A. Phillips, Simple Alternating Transit Mazes, unpublished. Abridged version appeared as La topologia dei labirinti, in M. Emmer, editor, L'Occhio di Horus: Itinerari nell'Imaginario Matematico. Istituto della Enciclopedia Italia, Rome, 1989, pp. 57-67.
  • J. A. Reeds and L. A. Shepp, An upper bound on the meander constant, preprint, May 25, 1999. [Obtains upper bound of 13.01]
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Extensions

Computed to n = 43 by Iwan Jensen

A000560 Number of ways of folding a strip of n labeled stamps.

Original entry on oeis.org

1, 2, 5, 12, 33, 87, 252, 703, 2105, 6099, 18689, 55639, 173423, 526937, 1664094, 5137233, 16393315, 51255709, 164951529, 521138861, 1688959630, 5382512216, 17547919924, 56335234064, 184596351277, 596362337295, 1962723402375
Offset: 2

Keywords

References

  • A. Sade, Sur les Chevauchements des Permutations, published by the author, Marseille, 1949.
  • 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).
  • M. B. Wells, Elements of Combinatorial Computing. Pergamon, Oxford, 1971, p. 238.

Crossrefs

Programs

Formula

a(n) = (1/2)*A000682(n+1) for n >= 2.
a(n) = A000136(n+1)/(2*n+2) for n >= 2. - Jean-François Alcover, Sep 06 2019 (from formula in A000136)

Extensions

Computed to n = 45 by Iwan Jensen - see link in A000682.

A001010 Number of symmetric foldings of a strip of n stamps.

Original entry on oeis.org

1, 2, 2, 4, 6, 8, 18, 20, 56, 48, 178, 132, 574, 348, 1870, 1008, 6144, 2812, 20314, 8420, 67534, 24396, 225472, 74756, 755672, 222556, 2540406, 693692, 8564622, 2107748, 28941258, 6656376, 98011464, 20548932, 332523306, 65573260, 1130110294, 205022836, 3846372944, 659806116, 13109737832, 2084555444, 44735866296, 6755838520
Offset: 1

Keywords

References

  • 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).

Crossrefs

Programs

  • Mathematica
    A000682 = Import["https://oeis.org/A000682/b000682.txt", "Table"][[All, 2]];
    A007822 = Cases[Import["https://oeis.org/A007822/b007822.txt", "Table"], {, }][[All, 2]];
    a[n_] := Which[n == 1, 1, EvenQ[n], 2*A000682[[n/2 + 1]], OddQ[n], 2*A007822[[(n - 1)/2 + 1]]];
    Array[a, 52] (* Jean-François Alcover, Sep 03 2019, updated Jul 13 2022 *)

Formula

a(1) = 1, a(2n-1) = 2*A007822(n), a(2n) = 2*A000682(n+1). - Sean A. Irvine, Mar 18 2013; corrected by Hunter Hogan, Aug 08 2025

A001011 Number of ways to fold a strip of n blank stamps.

Original entry on oeis.org

1, 1, 2, 5, 14, 38, 120, 353, 1148, 3527, 11622, 36627, 121622, 389560, 1301140, 4215748, 14146335, 46235800, 155741571, 512559195, 1732007938, 5732533570, 19423092113, 64590165281, 219349187968, 732358098471, 2492051377341, 8349072895553, 28459491475593
Offset: 1

Keywords

References

  • M. Gardner, Mathematical Games, Sci. Amer. Vol. 209 (No. 3, Mar. 1963), p. 262.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence - see entry 576, Fig. 17, and the front cover).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

Formula

a(n) = (A001010(n) + A000136(n)) / 4 for n >= 2. - Andrew Howroyd, Dec 07 2015

Extensions

a(17) and a(20) corrected by Sean A. Irvine, Mar 17 2013