Let $p\in (0,1)$ fixed. Let $S_n$ a random walk on $\mathbb Z$ starting at $0$ and s.t. $$\mathbb P(S_n=k\mid S_{n-1}=k-1)=p\quad \text{and}\quad \mathbb P(S_n=k\mid S_{n-1}=k+1)=1-p,\quad k\in\mathbb Z.$$ Can I find a closed form of $$f_n(k)=\mathbb P(S_n=k),$$ for $n\in\mathbb N$ and $k\in\mathbb Z$ ?
Attempts
We have that $f_0(k)=\boldsymbol 1_{\{0\}}(k)$. For $f_1$,
$$f_1(k)=\begin{cases} p&k=1\\ 1-p&k=-1\\ 0&otherwise. \end{cases} $$
For $f_2$,
$$f_2(k)=\begin{cases} p(1-p)&k=0\\ p^2&k=2\\ (1-p)^2&k=-2\\ 0&otherwise. \end{cases} $$
For $f_3$ $$f_3(k)=\begin{cases} p^3&k=3\\ p^2(1-p)&k=1\\ p(1-p)^2&k=-1\\ (1-p)^3&k=-3\\ 0&otherwise. \end{cases} $$
I highly suspect that $f_n(k)=p^s(1-p)^t$ for $s+t=n$, but I'm no so sure how to find $s$ and $t$ depending on $k$. Is there any simple way to compute it ?
$\mathbb P\{S_n=k\}=\binom{n}{k}p^k(1-p)^{n-k}$ is wrong.
If you take $s$ positive steps and $t$ negative steps in some pattern then you have an outcome of $S_n=k$ with $n=s+t$ and $k=s-t$, so $s=(n+k)/2$ and $t=(n-k)/2$, which answers your actual question "I'm not so sure how to find $s$ and $t$ depending on $k$".
Each particular pattern of $s$ positive and $t$ negative steps has probability $p^s(1-p)^t$.
The number of patterns of $s$ positive steps and $t$ negative steps is $\binom{s+t}{s} =\binom{n}{(n+k)/2}$, taking this to be $0$ when $(n+k)/2$ or $n$ are not integers or $n<0$ or $|k|>n$. Note that $n$ and $k$ must have the same parity for a pattern to be possible, and that $k$ can be negative.
So $$\mathbb P\{S_n=k\}=\binom{s+t}{s}p^s(1-p)^{t}=\binom{n}{(n+k)/2}p^{(n+k)/2}(1-p)^{(n-k)/2}.$$