Update
Thanks to the comment by @Gerry Myerson. Now I understand it is a question on Linear Congruential Generator(LCG). I have done some search on this topic and find this answer. Although it does not answer this question directly, it did actually solve my problem. This question could be closed or anyone can post an proper answer to this question (I am not sure if it exists).
Thank you for everyone who have commented!
Question
For a function $f(x)=ax+b \mod 2^{n}$, if we take any number as the first input and apply function recursively, it generates a sequence.
e.g. let $n=4,a=3,b=1,k=5$
$f^1(k)=5*3+1\mod16=0$
$f^2(k)=0*3+1\mod16=1$
$f^3(k)=1*3+1\mod16=4$
$f^4(k)=4*3+1\mod16=13$
$f^5(k)=13*3+1\mod16=8$
$f^6(k)=8*3+1\mod16=9$
$f^7(k)=9*3+1\mod16=12$
$f^8(k)=12*3+1\mod16=5$
Because of the modulo, it will eventually enters a loop. In this case $f^8(5)=5$ which means the loop size is 8. I want to know if there is a way to decide when $a$, $b$ and $n$ is big other than to calculate them one by one.
Some contexts
This question comes from a pseudo random generation function from a library of C. The random number is as follows:
$$
state[i+1] = a*state[i]+b \mod{2^{32}}
$$
$$
rng=state[i] \mod{2^{31}}
$$
My instinct is that this could be answered by field theory because if we remove the "$+b$" in that function:
$$
state[i+1] = a*state[i] \mod{2^{32}}
$$
Then the question is similar to "Is $a$ a generator of the field". But (@Thomas Andrews) reminds me that modulo of $2^{32}$ is not a field because not every element has a inverse.
So I am stuck here. I don't even know which key word should I search.
Original Question
For a Finite Field $F(2^{32})$ and a function $f(x)=ax+b$, where $a, b\in F$. How do we decide if $f(x)$ is a generator function of the field $F$?