This is similar to the idea of generating functions, if you would like more to read!
You might like https://www2.math.upenn.edu/~wilf/gfology2.pdf
You might like https://www2.math.upenn.edu/~wilf/gfology2.pdf