login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A338229 Number of ternary strings of length n that contain at least one 0 and at most two 1's. 2
0, 1, 5, 19, 61, 176, 474, 1219, 3035, 7378, 17608, 41405, 96177, 221092, 503702, 1138567, 2555767, 5701478, 12648276, 27918145, 61341485, 134217496, 292552450, 635436779, 1375731411, 2969566906, 6392118944, 13723762309, 29393682025, 62813896268, 133949292078, 285078453775, 605590388207 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
LINKS
FORMULA
a(n) = 2^n + n*2^(n-1) + binomial(n,2)*2^(n-2) - binomial(n,2) - n - 1.
E.g.f.: exp(x)*(exp(x) - 1)*(2 + 2*x + x^2)/2.
G.f.: x*(1 - 4*x + 7*x^2 - 8*x^3 + 5*x^4)/(1 - 3*x + 2*x^2)^3. - Stefano Spezia, Jan 31 2021
EXAMPLE
a(3) = 19 since the strings are composed of 000, the 6 permutations of 012, and the 3 permutations of 001, 002, 011 and 022. The total number of strings is then 1 + 6 + 3 + 3 + 3 + 3 = 19.
MATHEMATICA
CoefficientList[Series[Exp[x](Exp[x]-1)(2+2x+x^2)/2, {x, 0, 32}], x]Table[i!, {i, 0, 32}] (* Stefano Spezia, Jan 31 2021 *)
LinearRecurrence[{9, -33, 63, -66, 36, -8}, {0, 1, 5, 19, 61, 176}, 40] (* Harvey P. Dale, Mar 23 2022 *)
CROSSREFS
Sequence in context: A189714 A128638 A036630 * A102841 A036637 A036644
KEYWORD
nonn,easy
AUTHOR
Enrique Navarrete, Jan 30 2021
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 01:35 EDT 2024. Contains 371964 sequences. (Running on oeis4.)