how do I derive the system equation for a simple delay with feedback?
In such cases it helps to define an additional signal $w[n]$ at the input of the delay. Now you can write down two equations describing the system:

$$\begin{align}w[n]&amp;=x[n]+g\cdot w[n-N]\\y[n]&amp;=x[n]+w[n-N]\end{align}\tag{1}$$

where $N$ denotes the delay (in samples) and $g$ is the feedback gain. From the second equation you can express $w[n-N]$ in terms of $x[n]$ and $y[n]$:

$$w[n-N]=y[n]-x[n]\tag{2}$$

Plugging this into the first equation gives

$$y[n+N]-x[n+N]=x[n]+g\cdot \left(y[n]-x[n]\right)\tag{3}$$

Rearranging and subtracting $N$ from all indices results in

$$y[n]=x[n]+(1-g)x[n-N]+g\cdot y[n-N]\tag{4}$$

Eq. $(4)$ is the (single) difference equation describing the system. However, it's more efficient to implement the system using the two equations given in $(1)$.