A292805
Number of sets of nonempty words with a total of n letters over n-ary alphabet.
Original entry on oeis.org
1, 1, 5, 55, 729, 12376, 250735, 5904746, 158210353, 4747112731, 157545928646, 5726207734545, 226093266070501, 9632339536696943, 440262935648935344, 21482974431740480311, 1114363790702406540897, 61219233429920494716931, 3550130647865299090804375
Offset: 0
a(0) = 1: {}.
a(1) = 1: {a}.
a(2) = 5: {aa}, {ab}, {ba}, {bb}, {a,b}.
-
h:= proc(n, i, k) option remember; `if`(n=0, 1, `if`(i<1, 0,
add(h(n-i*j, i-1, k)*binomial(k^i, j), j=0..n/i)))
end:
a:= n-> h(n$3):
seq(a(n), n=0..20);
-
h[n_, i_, k_] := h[n, i, k] = If[n == 0, 1, If[i < 1, 0, Sum[h[n - i*j, i - 1, k]*Binomial[k^i, j], {j, 0, n/i}]]];
a[n_] := h[n, n, n];
Table[a[n], {n, 0, 20}] (* Jean-François Alcover, Jun 04 2018, from Maple *)
A292873
Total number of words beginning with the first letter of an n-ary alphabet in all multisets of nonempty words with a total of n letters.
Original entry on oeis.org
0, 1, 5, 37, 415, 6051, 109476, 2348767, 58191451, 1631827927, 51029454163, 1758883278967, 66200568699170, 2699977173047181, 118561410689195358, 5574984887552288475, 279398986674750754195, 14863338415349068099348, 836304620387823727353480
Offset: 0
For n=2 and alphabet {a,b} we have 7 multisets: {aa}, {ab}, {ba}, {bb}, {a,a}, {a,b}, {b,b}. There is a total of 5 words beginning with the first alphabet letter, thus a(2) = 5.
-
h:= proc(n, i, k) option remember; `if`(n=0, [1, 0], `if`(i<1, 0, add(
(p-> p+[0, p[1]*j])(binomial(k^i+j-1, j)*h(n-i*j, i-1, k)), j=0..n/i)))
end:
a:= n-> `if`(n=0, 0, h(n$3)[2]/n):
seq(a(n), n=0..22);
-
h[n_, i_, k_] := h[n, i, k] = If[n == 0, {1, 0}, If[i < 1, {0, 0}, Sum[ Function[p, p + {0, p[[1]]*j}][Binomial[k^i + j - 1, j]*h[n - i*j, i - 1, k]], {j, 0, n/i}]]];
a[n_] := If[n == 0, 0, h[n, n, n][[2]]/n];
Table[a[n], {n, 0, 22}] (* Jean-François Alcover, Mar 19 2022, after Alois P. Heinz *)
A378203
Number of palindromic n-ary words of length n that include the last letter of their respective alphabet.
Original entry on oeis.org
1, 1, 1, 5, 7, 61, 91, 1105, 1695, 26281, 40951, 771561, 1214423, 26916709, 42664987, 1087101569, 1732076671, 49868399761, 79771413871, 2560599031177, 4108933742199, 145477500542221, 234040800869107, 9059621800971105, 14605723004036255, 613627780919407801
Offset: 0
a(0) = 1: ().
a(1) = 1: (a).
a(2) = 1: (b,b).
a(3) = 5: (a,c,a), (b,c,b), (c,a,c), (c,b,c), (c,c,c).
-
a:= n-> (h-> n^h-`if`(n=0, 0, (n-1)^h))(ceil(n/2)):
seq(a(n), n=0..25); # Alois P. Heinz, Nov 21 2024
-
h[n_] := Ceiling[n/2];a[n_] := n^h[n] - (n - 1)^h[n];Join[{1},Table[a[n],{n,25}]] (* James C. McMahon, Nov 21 2024 *)
-
h(n) = {ceil(n/2)}
a(n) = {n^h(n)-(n-1)^h(n)}
-
def A378203(n): return n**(m:=n+1>>1)-(n-1)**m if n else 1 # Chai Wah Wu, Nov 21 2024
Showing 1-3 of 3 results.