I have two difference equations which I need to solve. They are important since I want to use them to derive important results in optimal stopping theory. The first equation is
$$k_s = p \cdot s + q \cdot k_{s-1}$$
where $p, q$ are constants. And $k_0=q \cdot D$
I know that the result is $k_s = -\frac{q}{p} + s + c \cdot q^s$
where $c = D + \frac{1}{p}$ but I do not know how to derive it.
The second problem is very similar to this one and involves solving the difference equation
$$k_s = p \cdot (1 - \frac{s}{N}) + q \cdot k_{s-1}$$
where $p, q, N$ are constants and the initial condition again is $k_0=q \cdot D$
Hint.
The recurrence
$$ k_s-q k_{s-1} = ps,\ \ \ k_0 = q D $$
is a linear recurrence and it's solution can be written as
$$ k_s = k_s^h + k_s^p $$
such that
$$ k_s^h-q k_{s-1}^h = 0\\ k_s^p-q k_{s-1}^p = ps $$
the homogeneous solution can be solved as
$$ k_s^h = C q^s $$
and now assuming $k_s^p = C_s q^s$ and substituting we obtain the recurrence for $C_s$
$$ C_s-C_{s-1} = p s q^{-s} $$
with solution
$$ C_s = \frac{p q^{1-s}\left(q^s+(\frac 1q-1)s-1\right)}{(q-1)^2} $$
and the full solution is
$$ k_s = \left(C - \frac{p q^{1-s}\left(q^s+(\frac 1q-1)s-1\right)}{(q-1)^2}\right)q^s $$
and after the introduction of the initial conditions
$$ k_s = \frac{q^{s+1} \left(D (q-1)^2+p\right)-p ((q-1) s+q)}{(q-1)^2} $$
The recurrence
$$k_s = p \cdot (1 - \frac{s}{N}) + q \cdot k_{s-1}$$
can be solved as well using the same method.