Let's say, the amount $P$ is borrowed on which interest is payable at the rate of $i$ per installment period. This amount is to be paid back along with interest in $n$ equal installments.
Let these installments be $I_1,I_2,I_3,\ldots,I_n$ respectively. Since they are all equal, we can say:$$I_1=I_2=I_3=\dots=I_n=I\label{a}\tag{1}$$
Each installment comprises some part of the principal $P$ that is paid back, the rest is interest on the amount that was outstanding for that installment period. Let the part of the principal that is paid back with $I_1,I_2,I_3,\ldots,I_n$ respectively be $P_1,P_2,P_3,\ldots,P_n$. These principal payments must add up to the original amount $P$ that was borrowed:$$P_1+P_2+P_3+\cdots+P_n=P\label{b}\tag{2}$$
Now let's talk about interest. At the end of the first installment period, the entire principal $P$ will have been outstanding for the duration of one installment period. The interest payable in this regard is $P \times i$ which will be paid along with $P_1$ when $I_1$ is paid. Therefore, $I_1=P_1+P\times i$. At the end of the second installment period, only the amount $P-P_1$ will have been outstanding for the same period. Therefore, only $[P-P_1]\times i$ is payable as interest for the second installment period which will be paid along with $P_2$ when $I_2$ is paid. Similarly, at the end of the third installment period, interest will be paid only on $[P-(P_1+P_2)]$ for one installment period along with $P_3$ when $I_3$ is paid.
Making the above argument for all installments, we get:
$$I_1=P_1+P\times i\label{c}\tag{3}$$
$$I_2=P_2+[P-P_1]\times i$$
$$I_3=P_3+[P-(P_1+P_2)]\times i$$
$$\vdots$$
$$I_n=P_n+[P-(P_1+P_2+\dots+P_{n-1})]\times i$$
If we add up the above equations, we get:
$$I_1+I_2+I_3+\cdots+I_n=[P_1+P\times i]+[P_2+[P-P_1]\times i]+[P_3+[P-(P_1+P_2)]\times i]+\cdots+[P_n+[P-(P_1+P_2+\dots+P_{n-1})]\times i]$$
$$I_1+I_2+I_3+\cdots+I_n=[P_1+P_2+P_3+\cdots+P_n]+P\times i+[P-P_1]\times i+[P-(P_1+P_2)]\times i+\cdots+[P-(P_1+P_2+\cdots+P_n)]\times i$$
$$I_1+I_2+I_3+\cdots+I_n=[P_1+P_2+P_3+\cdots+P_n]+P\times i+P\times i-P_1\times i+P\times i-(P_1+P_2)\times i+\cdots+P\times i-(P_1+P_2+\cdots+P_n)\times i$$
$$I_1+I_2+I_3+\cdots+I_n=[P_1+P_2+P_3+\cdots+P_n]+n\times P\times i-[P_1+(P_1+P_2)+\cdots+(P_1+P_2+\cdots+P_{n-1})]\times i$$
Remember that $I_1=I_2=I_3=\dots=I_n=I$ (from \ref{a}) and $P_1+P_2+P_3+\cdots+P_n=P$ (from \ref{b}):
$$n\times I=P+n\times P\times i-[P_1+(P_1+P_2)+\cdots+(P_1+P_2+\cdots+P_{n-1})]\times i\label{d}\tag{4}$$
Now, let $j$ be a natural number such that $j \in [2,n-1]$. $I_j$ and $I_{j+1}$ are given as follows:
$$I_j=P_j+[P-\sum_{k=1}^{j-1} P_k]\times i$$
$$I_{j+1}=P_{j+1}+[P-\sum_{k=1}^{j} P_k]\times i$$
Consider $I_{j+1}-I_j$:
$$I_{j+1}-I_j=P_{j+1}+[P-\sum_{k=1}^{j} P_k]\times i-(P_j+[P-\sum_{k=1}^{j-1} P_k]\times i)$$
$$I_{j+1}-I_j=P_{j+1}+P\times i-\sum_{k=1}^{j} P_k\times i-P_j-[P-\sum_{k=1}^{j-1} P_k]\times i$$
$$I_{j+1}-I_j=P_{j+1}+\require{cancel} \cancel{P\times i}-\sum_{k=1}^{j} P_k\times i-P_j-\require{cancel} \cancel{P\times i}+\sum_{k=1}^{j-1} P_k\times i$$
$$I_{j+1}-I_j=P_{j+1}-(\sum_{k=1}^{j-1} P_k\times i+P_j\times i)-P_j+\sum_{k=1}^{j-1} P_k\times i$$
$$I_{j+1}-I_j=P_{j+1}-\require{cancel}\cancel{\sum_{k=1}^{j-1} P_k\times i}-P_j\times i-P_j+\require{cancel}\cancel{\sum_{k=1}^{j-1} P_k\times i}$$
$$I_{j+1}-I_j=P_{j+1}-P_j\times i-P_j$$
Remember that $I_j=I_{j+1}=I$ (from \ref{a}):
$$\require{cancel}\cancel{I_{j+1}}-\require{cancel}\cancel{I_j}=P_{j+1}-P_j\times i-P_j$$
$$0=P_{j+1}-P_j\times i-P_j$$
$$P_{j+1}=P_j\times(i+1);\ j \in [2,n-1]\label{e}\tag{5}$$
Now, consider $I_2-I_1$:
$$I_2-I_1=P_2+[P-P_1]\times i-(P_1+P\times i)$$
$$I_2-I_1=P_2+\require{cancel}\cancel{P\times i}-P_1\times i-P_1-\require{cancel}\cancel{P\times i}$$
$$I_2-I_1=P_2-P_1\times i-P_1$$
Again, since $I_1=I_2=I$ (from \ref{a}):
$$\require{cancel}\cancel{I_2}-\require{cancel}\cancel{I_1}=P_2-P_1\times i-P_1$$
$$0=P_2-P_1\times i-P_1$$
$$P_2=P_1\times(i+1)$$
If we expand out $\ P_{j+1}=P_j\times(i+1);\ j \in [2,n-1]$ (from \ref{e}) and add $P_2=P_1\times(i+1)$ to the resulting set of equations, we get:
$$P_1=P_1$$
$$P_2=P_1\times(i+1)$$
$$P_3=P_2\times(i+1)$$
$$\vdots$$
$$P_j=P_{j-1}\times(i+1)$$
$$\vdots$$
$$P_{n-1}=P_{n-2}\times(i+1)$$
$$P_n=P_{n-1}\times(i+1)$$
Multiplying the above equations gives us:
$$P_1\times P_2\times P_3\times\cdots\times P_{n-1}\times P_n=P_1\times [P_1\times(i+1)]\times [P_2\times(i+1)]\times\cdots\times [P_{n-2}\times(i+1)]\times [P_{n-1}\times(i+1)]$$
$$\require{cancel}\cancel{P_1}\times \require{cancel}\cancel{P_2}\times \require{cancel}\cancel{P_3}\times\cdots\times \require{cancel}\cancel{P_{n-1}}\times P_n=P_1\times [\require{cancel}\cancel{P_1}\times(i+1)]\times [\require{cancel}\cancel{P_2}\times(i+1)]\times\cdots\times [\require{cancel}\cancel{P_{n-2}}\times(i+1)]\times [\require{cancel}\cancel{P_{n-1}}\times(i+1)]$$
$$P_n=P_1\times [(i+1)\times (i+1)\times\cdots\text{$(n-1)$ times}]$$
$$P_n=P_1\times(i+1)^{n-1}\label{f}\tag{6}$$
Now we would like to have an expression for $\sum_{k=1}^j P_k;\ j \in [1,n]$. The same set of equations that helped us figure out \ref{f} will be useful in this regard:
$$\sum_{k=1}^{j} P_k=P_1+P_2+P_3+\cdots+P_j$$
$$\sum_{k=1}^{j} P_k=P_1+P_1\times(i+1)+P_2\times(i+1)+\cdots+P_{j-1}\times(i+1)$$
$$\sum_{k=1}^{j} P_k=P_1+[P_1+P_2+\cdots+P_{j-1}]\times (i+1)$$
$$\sum_{k=1}^{j} P_k=P_1+[P_1+P_2+\cdots+P_{j-1}+P_j-P_j]\times (i+1)$$
$$\sum_{k=1}^{j} P_k=P_1+[\sum_{k=1}^{j} P_k-P_j]\times (i+1)$$
$$\sum_{k=1}^{j} P_k=P_1+\left(\sum_{k=1}^{j} P_k\right)\times (i+1)-P_j\times (i+1)$$
$$\require{cancel}\cancel{\sum_{k=1}^{j} P_k}=P_1+i\times \sum_{k=1}^{j}P_k+\require{cancel}\cancel{\sum_{k=1}^{j} P_k}-P_j\times (i+1)$$
$$0=P_1+i\times \sum_{k=1}^{j}P_k-P_j\times (i+1)$$
$$i\times \sum_{k=1}^{j}P_k=P_j\times (i+1)-P_1$$
$$\sum_{k=1}^{j}P_k=\frac{P_j\times (i+1)-P_1}{i}; \ j \in [1,n]\label{g}\tag{7}$$
We get the following equations by using \ref{g}:
$$P_1=\frac{P_1\times (i+1)-P_1}{i}$$
$$P_1+P_2=\frac{P_2\times (i+1)-P_1}{i}$$
$$P_1+P_2+P_3=\frac{P_3\times (i+1)-P_1}{i}$$
$$\vdots$$
$$P_1+P_2+P_3+\cdots+P_{n-1}=\frac{P_{n-1}\times (i+1)-P_1}{i}$$
Add these up to get the following:
$$P_1+(P_1+P_2)+(P_1+P_2+P_3)+\cdots+(P_1+P_2+P_3+\cdots+P_{n-1})=\frac{P_1\times (i+1)-P_1}{i}+\frac{P_2\times (i+1)-P_1}{i}+\frac{P_3\times (i+1)-P_1}{i}+\cdots+\frac{P_{n-1}\times (i+1)-P_1}{i}$$
$$P_1+(P_1+P_2)+(P_1+P_2+P_3)+\cdots+(P_1+P_2+P_3+\cdots+P_{n-1})=\frac{(P_1\times (i+1)-P_1)+(P_2\times (i+1)-P_1)+(P_3\times (i+1)-P_1)+\cdots+(P_{n-1}\times (i+1)-P_1)}{i}$$
$$P_1+(P_1+P_2)+(P_1+P_2+P_3)+\cdots+(P_1+P_2+P_3+\cdots+P_{n-1})=\frac{(P_1+P_2+P_3+\cdots+P_{n-1})\times (i+1)-P_1\times (n-1)}{i}$$
$$P_1+(P_1+P_2)+(P_1+P_2+P_3)+\cdots+(P_1+P_2+P_3+\cdots+P_{n-1})=\frac{(P_1+P_2+P_3+\cdots+P_{n-1}+P_n-P_n)\times (i+1)-P_1\times (n-1)}{i}$$
Substitute the value of $P_1+P_2+P_3+\cdots+P_{n-1}+P_n$ from \ref{b}:
$$P_1+(P_1+P_2)+(P_1+P_2+P_3)+\cdots+(P_1+P_2+P_3+\cdots+P_{n-1})=\frac{(P-P_n)\times (i+1)-P_1\times (n-1)}{i}$$
Substitute the value of $P_n$ from \ref{f}:
$$P_1+(P_1+P_2)+(P_1+P_2+P_3)+\cdots+(P_1+P_2+P_3+\cdots+P_{n-1})=\frac{(P-P_1\times(i+1)^{n-1})\times (i+1)-P_1\times (n-1)}{i}$$
$$P_1+(P_1+P_2)+(P_1+P_2+P_3)+\cdots+(P_1+P_2+P_3+\cdots+P_{n-1})=\frac{P\times (i+1)-P_1\times(i+1)^n-P_1\times (n-1)}{i}$$
$$P_1+(P_1+P_2)+(P_1+P_2+P_3)+\cdots+(P_1+P_2+P_3+\cdots+P_{n-1})=\frac{P\times (i+1)-P_1\times\Bigl((i+1)^n+(n-1)\Bigr)}{i}\label{h}\tag{8}$$
Substitute the value of $P_1+(P_1+P_2)+(P_1+P_2+P_3)+\cdots+(P_1+P_2+P_3+\cdots+P_{n-1})$ from \ref{h} in \ref{d}:
$$n\times I=P+n\times P\times i-\left(\frac{P\times (i+1)-P_1\times\Bigl((i+1)^n+(n-1)\Bigr)}{\require{cancel}\cancel{i}}\right)\times \require{cancel}\cancel{i}$$
$$n\times I=P+n\times P\times i-\biggl(P\times (i+1)-P_1\times\Bigl((i+1)^n+(n-1)\Bigr)\biggr)$$
$$n\times I=P+n\times P\times i-P\times (i+1)+P_1\times\Bigl((i+1)^n+(n-1)\Bigr)$$
$$n\times I=\require{cancel}\cancel{P}+n\times P\times i-P\times i-\require{cancel}\cancel{P}+P_1\times\Bigl((i+1)^n+(n-1)\Bigr)$$
$$n\times I=n\times P\times i-P\times i+P_1\times\Bigl((i+1)^n+(n-1)\Bigr)$$
$$P_1\times\Bigl((i+1)^n+(n-1)\Bigr)=n\times I+P\times i-n\times P\times i$$
$$P_1=\frac{n\times I+P\times i-n\times P\times i}{(i+1)^n+(n-1)}\label{i}\tag{9}$$
Substitute the value of $P_1$ from \ref{i} in \ref{c}:
$$I_1=\frac{n\times I+P\times i-n\times P\times i}{(i+1)^n+(n-1)}+P\times i$$
We know that $I_1=I$ from \ref{a}:
$$I=\frac{n\times I+P\times i-n\times P\times i}{(i+1)^n+(n-1)}+P\times i$$
$$I\times \Bigl((i+1)^n+(n-1)\Bigr)=\left(\frac{n\times I+P\times i-n\times P\times i}{\require{cancel}\cancel{(i+1)^n+(n-1)}}\right)\times \require{cancel}\cancel{\Bigl((i+1)^n+(n-1)\Bigr)}+P\times i\times \Bigl((i+1)^n+(n-1)\Bigr)$$
$$I\times \Bigl((i+1)^n+(n-1)\Bigr)-n\times I=P\times i-n\times P\times i+P\times i\times \Bigl((i+1)^n+(n-1)\Bigr)$$
$$I\times \Bigl((i+1)^n+(\require{cancel}\cancel{n}-1)-\require{cancel}\cancel{n}\Bigr)=P\times i\times(1-n)+P\times i\times (i+1)^n+P\times i\times(n-1)$$
$$I\times \Bigl((i+1)^n-1\Bigr)=-\require{cancel}\cancel{P\times i\times(n-1)}+P\times i\times (i+1)^n+\require{cancel}\cancel{P\times i\times(n-1)}$$
$$I\times \Bigl((i+1)^n-1\Bigr)=P\times i\times (i+1)^n$$
$$I=\frac{P\times i\times (i+1)^n}{(i+1)^n-1}$$