Suppose there's a looped sequence $A=(a_0\ldots a_n)$ and, since it is a looped sequence, $a_0=a_n$.
Given $M$, is there a way to determine whether said sequence can be produced by a formula $$A_i=(p^ia+b\sum_{k=0}^{i-1}{p^k})\pmod M$$
In other words, given a looped sequence $A$, how can we determine if there exist a pair of $(p, b)$ such that the following sequence defines it beautifully? $$a_0\\(p a_0+b)\pmod M\\(p^2a_0+pb+b)\pmod M\\ \ldots $$
For example, given $M=16$, a looped sequence of $(1, 12,3,6,5,0,7,10,9,4,11,14,13,8,15,2,1)$ can be defined by choosing $p=5$, $b=7$: $$A_i=(5^ia+7\sum_{k=0}^{i-1}{5^k})\pmod {16}$$
How can we determine if an arbitrary looped sequence can be presented in such manner?