Skip to main content
1 of 2
alephalpha
  • 50k
  • 7
  • 68
  • 182

Pari/GP, 48 bytes

The generating function of the sequence is:

$$\frac{(n-1)x^n}{x^{n+1}-2x+1}-\frac{1}{x-1}$$

(n,m)->Vec(x^n/((x^n-2)*x+1)*n---1/(x-1)+O(x^m))

Try it online!

alephalpha
  • 50k
  • 7
  • 68
  • 182