First note that
\begin{equation*}
\Delta x = \dfrac{b-a}{n} = \dfrac{2}{n}
\end{equation*}
For
\(x_i\text{,}\) we have
\begin{equation*}
x_i = a + i\Delta x = 2 + \dfrac{2i}{n}
\end{equation*}
This means that
\begin{equation*}
f(x_i) = 2 + \dfrac{2i}{n}
\end{equation*}
So that the area of a single rectangle is given by
\begin{equation*}
f(x_i)\Delta x = \lrpar{2+\dfrac{2i}{n}}\cdot \dfrac{2}{n} = \dfrac{4}{n} + \dfrac{4i}{n^2}
\end{equation*}
And the sum of a finite number of rectangles is
\begin{equation*}
\ds \sum_{i=1}^n f(x_i)\Delta x = \sum_{i=1}^n \dfrac{4}{n} + \dfrac{4i}{n^2} = 4 + \dfrac{2n(n+1)}{n^2}
\end{equation*}
after using the helpful formulas given below. Now, the integral can be computed by taking the limit:
\begin{equation*}
\ds \int_2^4 x\, dx = \lim_{n\to\infty} \sum_{i=1}^n f(x_i)\Delta x = 4 + 2 = 6
\end{equation*}
So the definite integral is 6.