It has been years since I've done any math related to this but my gut reaction is that you should be able to setup and solve a recurrence relation. You'll probably end up with a polynomial and all of the roots of the polynomial would be solutions.

A question like this is probably better suited at

MathOverflow.