Given an integer polynomial $Q(x_1,x_2,...,x_m)$, let $N(p,n)$ denote the number of solutions to the equation $$Q(x_1,...,x_m) \equiv 0$$ modulo $p^n.$
We can consider the ordinary generating functions $$F(p,x) = \sum_{n=0}^{\infty} N(p,n) x^n.$$ I find experimentally that these $F(p,x)$ tend to be rational functions.
Here are a few examples:
(1) If $Q(x) = x^2$, then $$F(2,x) = 1 + x + 2x^2 + 2x^3 + 4x^4 + 4x^5 + ... = \frac{1+x}{1 - 2x^2}.$$ More generally, $F(p,x)$ is $\frac{1+x}{1-px^2}$ for all primes $p$.
(2) If $Q(x) = x^3$, then for any prime $p$, $$F(p,x) = 1 + x + px^2 + p^2 x^3 + p^2 x^4 + p^3 x^5 + ... = \frac{1+x+px^2}{1 - p^2x^3}.$$
(3) If $Q(x,y) = x^2 + xy + 2y^2$, then $$F(2,x) = 1 + 3x + 8x^2 + 20x^3 + 48x^4 + 112x^5 + ... = \frac{1-x}{(1-2x)^2},$$ while $$F(5,x) = 1 + x + 25x^2 + 25x^3 + 625 x^4 + 625x^5 + ... = \frac{1+x}{1-25x^2}$$ and $$F(7,x) = 1 + 7x + 49x^2 + 343x^3 + ... = \frac{1}{1-7x}.$$
(4) If $Q(x,y,z) = -x^2 + 2y^2 + z^2 + xy + xz + yz$ then $$F(2,x) = 1 + 4x + 20x^2 + 80x^3 + 352x^4 + 1408x^5 + ... = \frac{1-4x^2}{(1-4x)(1-8x^2)}$$ and $$F(5,x) = 1 + 25x + 725x^2 + 18125x^3 + ... = \frac{1}{(1 - 25x)(1 - 100x^2)}.$$
Question: Is there a general result that says that this is always a rational function? If so, can we find bounds on the degree of the numerator and denominator? I am particularly interested in the case that $Q$ is a quadratic form.