Let $M$ be a real $n\times n$ matrix with all diagonal entries equal to $r$ and all non-diagonal entries equal to $s$. Compute the determinant of $M$. This was a question from ISI M.Math test $2021$.
My attempt: I tried directly computing for small $n$ to see if there are any patterns. For $n=1,2,3$ the determinants are respectively $r, r^2-s^2, r^3+2s^3-3rs^2$. I couldn't find any pattern other than the obvious fact that there has to an entry $r^n$ for each $n$ so that the identity matrix satisfies the formula. And the sum of the coefficients must be zero for $n>1$ (by having a matrix with all entries equal to $1$). But I can't proceed any further.