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

A007055 Let S denote the palindromes in the language {0,1}*; a(n) = number of words of length n in the language SS.

Original entry on oeis.org

1, 2, 4, 8, 16, 32, 52, 100, 160, 260, 424, 684, 1036, 1640, 2552, 3728, 5920, 8672, 13408, 19420, 30136, 42736, 66840, 94164, 145900, 204632, 317776, 441764, 685232, 950216, 1469632, 2031556, 3139360, 4323888, 6675904, 9174400, 14139496, 19398584, 29864888, 40891040, 62882680, 85983152
Offset: 0

Views

Author

Keywords

Comments

Number of words in {0,1}* of length n that are rotations of their reversals. - David W. Wilson, Jan 01 2012
a(n) = sum of the orbit sizes of all achiral necklaces (or bracelets) under the action of the cyclic (or dihedral) group. - Mathieu Gagne, Jul 29 2025

Examples

			S = {e, 0, 1, 11, 101, 111, 1001, 1111, 10001, 10101, 11011, 11111, 100001, ...}, where e is the empty word.
SS contains all words in {0,1}* of length <= 5, but at length 6 is missing the 12 words { 001011, 001101, 010011, 010110, 011001, 011010, 100101, 100110, 101001, 101100, 110010, 110100 }.
In more detail: All words in SS of length 6 have one of the following 6 patterns: abccba, abbacc, aabccb, abcbad, abacdc, abcdcb. This gives a total of 3*(2^3 + 2^4) = 72 = A187272(n) words with some words being counted multiple times as follows: (x6): 000000, 111111; (x3): 010101, 101010; (x2): 001001, 010010, 011011, 100100, 101101, 110110. These are exactly the repetitions of shorter words in SS. Subtracting gives a(6) = 72 - 5*2 - 2*2 - 1*6 = 52.
For length n=7: All words in SS of length 7 have one of the following 7 patterns: abcdcba, abccbad, abcbadd, abbacdc, abacddc, aabcdcb, abcddcb. This gives a total of 7*2^4 = 112 = A187272(n) words with some words being counted multiple times. In particular, the words 0000000 and 1111111 are counted 7 times each so a(7) = 112 - 6*2 = 100. - Information about examples courtesy of _Andrew Howroyd_, Mar 30 2016
For n=6, there are 2 achiral necklaces with orbit size s=1, 1 with s=2, 2 with s=3, and 7 with s=6, giving a total of 2*1+1*2+2*3+7*6 = 52. - _Mathieu Gagne_, Jul 29 2025
		

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Column 2 of A284873.
For the nonempty words in the language S, see A057148 and A006995.

Programs

  • Maple
    # A023900:
    f:=proc(n) local t0,t1,t2; if n=1 then RETURN(1) else
    t0:=1; t1:=ifactors(n); t2:=t1[2]; for i from 1 to nops(t2) do t0:=t0*(1-t2[i][1]); od; RETURN(t0); fi; end;
    # A187272, A187273, A187274, A187275:
    R:=(a,n)->
    expand(simplify( (n/4)*a^(n/2)*( (1+sqrt(a))^2+ (-1)^n*(1-sqrt(a))^2 ) ));
    # A007055, A007056, A007057, A007058
    F:=(b,n)-> if n=0 then 1 else expand(simplify( add( f(d)*R(b,n/d),d in divisors(n) ) )); fi;
    # A007055:
    [seq(F(2,n),n=0..60)];
  • Mathematica
    A187272[n_] := A187272[n] = (n/4)*2^(n/2)*((1 + Sqrt[2])^2 + (-1)^n*(1 - Sqrt[2])^2) // Round;
    a[n_ /; n <= 5] := 2^n; a[n_] := a[n] = A187272[n] - Sum[n, EulerPhi[n/d] * a[d], {d, Most[Divisors[n]]}];
    Table[a[n], {n, 0, 41}] (* Jean-François Alcover, Oct 08 2017, after Andrew Howroyd *)
    Table[Sum[s * Sum[MoebiusMu[s/d] If[EvenQ[d], 3*2^((d/2) - 1), 2^((d + 1)/2)] , {d, Divisors[s]}], {s, Divisors[n]}], {n, 1, 41}] (* Mathieu Gagne, Jul 29 2025 *)
  • Python
    from functools import lru_cache
    from sympy import totient, proper_divisors
    @lru_cache(maxsize=None)
    def A007055(n): return (n<<(n+1>>1) if n&1 else 3*n<<(n-2>>1))-sum(totient(n//d)*A007055(d) for d in proper_divisors(n,generator=True)) if n else 1 # Chai Wah Wu, Feb 18 2024

Formula

a(n) = A187272(n) - Sum_{d|n, dAndrew Howroyd, Mar 29 2016
a(0)=1; a(n) = Sum_{s|n} s * A056493(s) for n>0. - Mathieu Gagne, Jul 29 2025
a(0)=1; a(n) = Sum_{s|n} s * (Sum_{d|s} mu(d) * A164090(s/d)) for n>0. - Mathieu Gagne, Jul 29 2025

Extensions

Entry revised by N. J. A. Sloane, Mar 07 2011

A284873 Array read by antidiagonals: T(n,k) = number of double palindromes of length n using a maximum of k different symbols.

Original entry on oeis.org

1, 2, 1, 3, 4, 1, 4, 9, 8, 1, 5, 16, 21, 16, 1, 6, 25, 40, 57, 32, 1, 7, 36, 65, 136, 123, 52, 1, 8, 49, 96, 265, 304, 279, 100, 1, 9, 64, 133, 456, 605, 880, 549, 160, 1, 10, 81, 176, 721, 1056, 2125, 1768, 1209, 260, 1, 11, 100, 225, 1072, 1687, 4356, 4345, 4936, 2127, 424, 1
Offset: 1

Views

Author

Andrew Howroyd, Apr 04 2017

Keywords

Comments

A double palindrome is a concatenation of two palindromes.
Also, number of words of length n using a maximum of k different symbols that are rotations of their reversals.
The sequence A165135 (number of n-digit positive papaya numbers) is 9/10 of the value of column 10.
All rows are polynomials of degree 1 + floor(n/2). - Andrew Howroyd, Oct 10 2017
From Petros Hadjicostas, Oct 27 2017: (Start)
Following Kemp (1982), we note that the formula by A. Howroyd below is equivalent to r(n,k) = Sum_{d|n} phi(d)*T(n/d,k), where r(2d, k) = d*(k+1)*k^d and r(2d+1, k) = (2d+1)*k^(d+1). Inverting (according to the theory of Dirichlet convolutions) we get T(n,k) = Sum_{d|n} phi^{(-1)}(d)*r(n/d,k), where phi^{(-1)}(n) = A023900(n) is the Dirichlet inverse of Euler's totient function.
We can easily prove that Sum_{n>=1} r(n,k)*x^n = R(k,x) = k*x*(x+1)*(k*x+1)/(1-k*x^2)^2 (for each k>=1). We also have Sum_{n>=1} T(n,k)*x^n = Sum_{n>=1} Sum_{d|n} phi^{(-1)}(d)*r(n/d,k)*x^n. Letting m = n/d and noting that x^n = (x^d)^m, we can easily get the g.f. given in the formula section.
Note that r(n,1) = n, r(n,2) = A187272(n), r(n,3) = A187273(n), r(n,4) = A187274(n), and r(n,5) = A187275(n).
(End)

Examples

			Table starts:
  1   2    3     4     5      6      7       8       9      10 ...
  1   4    9    16    25     36     49      64      81     100 ...
  1   8   21    40    65     96    133     176     225     280 ...
  1  16   57   136   265    456    721    1072    1521    2080 ...
  1  32  123   304   605   1056   1687    2528    3609    4960 ...
  1  52  279   880  2125   4356   7987   13504   21465   32500 ...
  1 100  549  1768  4345   9036  16765   28624   45873   69940 ...
  1 160 1209  4936 14665  35736  75985  146224  260721  437680 ...
  1 260 2127  9112 27965  69756 150955  294512  530937  899380 ...
  1 424 4689 25216 93025 270936 670369 1471744 2948481 5494600 ...
From _Petros Hadjicostas_, Oct 27 2017: (Start)
We explain how to use the above formulae to find general expressions for some rows.
If p is an odd prime, then phi^{(-1)}(p) = 1-p. Since, also, phi^{(-1)}(1) = 1, we get T(p,k) = (1-p)*k+p*k^{(p+1)/2} for the p-th row above.
If m is a positive integer, then phi^{(-1)}(2^m) = -1, and so T(2^m,k) = 1+(k+1)*(2^{m-1}*k^{2^{m-1}}-1-Sum_{0<=s<=m-2} 2^s*k^{2^s}).
For example, if m=1, then T(2,k) = 1+(k+1)*(1*k-1-0) = k^2.
If m=2, then T(4,k) = 1+(k+1)*(2*k^2-1-k) = k*(2*k^2+k-2), which is the formula conjectured by C. Barker for sequence A187277 and verified by A. Howroyd.
(End)
		

Crossrefs

Columns 2-5 are A007055, A007056, A007057, A007058.
Rows 3-4 are A000567, A187277.

Programs

  • Mathematica
    r[d_, k_]:=If[OddQ[d], d*k^((d + 1)/2), (d/2)*(k + 1)*k^(d/2)]; a[n_, k_]:= r[n, k] - Sum[If[dIndranil Ghosh, Apr 07 2017 *)
  • PARI
    r(d,k)=if (d % 2 == 0, (d/2)*(k+1)*k^(d/2), d*k^((d+1)/2));
    a(n,k) = r(n,k) - sumdiv(n,d, if (d
    				
  • Python
    from sympy import totient, divisors
    def r(d, k): return (d//2)*(k + 1)*k**(d//2) if d%2 == 0 else d*k**((d + 1)//2)
    def a(n, k): return r(n, k) - sum([totient(n//d)*a(d, k) for d in divisors(n) if dIndranil Ghosh, Apr 07 2017

Formula

T(n, k) = r(n, k) - Sum_{d|n, d
From Petros Hadjicostas, Oct 27 2017: (Start)
T(n,k) = Sum_{d|n} phi^{(-1)}(d)*r(n/d,k), where r(n,k) is given above and phi^{(-1)}(n) = A023900(n) is the Dirichlet inverse of Euler's totient function.
G.f.: For each k>=1, Sum_{n>=1} T(n,k)*x^n = Sum_{d>=1} phi^{(-1)}(d)*R(k,x^d), where R(k,x) = k*x*(x+1)*(k*x+1)/(1-k*x^2)^2.
(End)
From Richard L. Ollerton, May 07 2021: (Start)
T(n,k) = Sum_{i=1..n} phi^{(-1)}(n/gcd(n,i))*r(gcd(n,i),k)/phi(n/gcd(n,i)).
T(n,k) = Sum_{i=1..n} phi^{(-1)}(gcd(n,i))*r(n/gcd(n,i),k)/phi(n/gcd(n,i)).
r(n,k) = Sum_{i=1..n} T(gcd(n,i),k). (End)

A187272 a(n) = (n/4)*2^(n/2)*((1+sqrt(2))^2 + (-1)^n*(1-sqrt(2))^2).

Original entry on oeis.org

0, 2, 6, 12, 24, 40, 72, 112, 192, 288, 480, 704, 1152, 1664, 2688, 3840, 6144, 8704, 13824, 19456, 30720, 43008, 67584, 94208, 147456, 204800, 319488, 442368, 688128, 950272, 1474560, 2031616, 3145728, 4325376, 6684672, 9175040, 14155776, 19398656, 29884416, 40894464, 62914560, 85983232
Offset: 0

Author

N. J. A. Sloane, Mar 07 2011

Keywords

Crossrefs

Programs

  • Magma
    [Round((n/4)*2^(n/2)*((1+Sqrt(2))^2 + (-1)^n*(1-Sqrt(2))^2)): n in [0..30]]; // G. C. Greubel, Nov 28 2017
    
  • Maple
    R:=(b,n)-> expand(simplify( (n/4)*b^(n/2)*((1+sqrt(b))^2+(-1)^n*(1-sqrt(b))^2) ));
    [seq(R(2,n),n=0..100)];
  • Mathematica
    CoefficientList[Series[2 x (1 + x) (1 + 2 x) / (1 - 2 x^2)^2, {x, 0, 40}], x] (* Vincenzo Librandi, Jun 19 2013 *)
  • PARI
    x='x+O('x^30); concat([0], Vec(2*x*(1+x)*(1+2*x)/(1-2*x^2)^2)) \\ G. C. Greubel, Nov 28 2017
    
  • Python
    def A187272(n): return (n<<(n+1>>1) if n&1 else 3*n<<(n-2>>1)) if n else 0 # Chai Wah Wu, Feb 18 2024

Formula

From Bruno Berselli, Mar 22 2011: (Start)
G.f.: 2*x*(1+x)*(1+2*x)/(1-2*x^2)^2.
a(n)/a(n-2) = 2*n/(n-2). (End)
a(2*n) = 3*n*2^n, a(2*n+1) = (2*n+1)*2^(n+1). - Andrew Howroyd, Mar 28 2016

A007056 Let S denote the palindromes in the language {0,1,2}*; a(n) = number of words of length n in the language SS.

Original entry on oeis.org

1, 3, 9, 21, 57, 123, 279, 549, 1209, 2127, 4689, 7989, 17031, 28395, 60615, 98061, 208569, 334563, 705789, 1121877, 2356737, 3718827, 7786359, 12223077, 25488903, 39857523, 82876257, 129135729, 267784119, 416118219, 860825439, 1334448261, 2754778809, 4261609131, 8781196329, 13559714109, 27893530029
Offset: 0

Author

Keywords

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Column 3 of A284873.

Programs

  • Maple
    See A007055.
  • Python
    from functools import lru_cache
    from sympy import totient, proper_divisors
    @lru_cache(maxsize=None)
    def A007056(n): return (n*3**(1+(n>>1)) if n&1 else (n<<1)*3**(n>>1))-sum(totient(n//d)*A007056(d) for d in proper_divisors(n,generator=True)) if n else 1 # Chai Wah Wu, Feb 19 2024

Formula

a(n) = A187273(n) - Sum_{d|n,dSean A. Irvine, Sep 27 2017

Extensions

Entry revised by N. J. A. Sloane, Mar 07 2011
Showing 1-4 of 4 results.