A $n$ by $n$ magic square contains numbers from $1$ to $n^2$ such that the sum of every row and every column is the same. What is this sum?
1. A magic square of size $n \times n$ contains the numbers from $1$ to $n^2$. The sum of all these numbers can be calculated using the formula for the sum of the first $n^2$ natural numbers:
   \[
   \sum_{k=1}^{n^2} k = \frac{n^2(n^2 + 1)}{2}
   \]

2. In a magic square, the sum of the numbers in each row, each column, and each diagonal is the same. Let this common sum be denoted by $S$.

3. Since there are $n$ rows in the magic square, and each row sums to $S$, the total sum of all the numbers in the magic square can also be expressed as:
   \[
   nS
   \]

4. Equating the two expressions for the total sum of the numbers, we get:
   \[
   nS = \frac{n^2(n^2 + 1)}{2}
   \]

5. Solving for $S$, we divide both sides of the equation by $n$:
   \[
   S = \frac{n^2(n^2 + 1)}{2n} = \frac{n(n^2 + 1)}{2}
   \]

Conclusion:
\[
\boxed{\frac{n(n^2 + 1)}{2}}
\]