To solve the problem, we start with the given condition for the function \( f \):
1. **Given Condition**:
\[
f(x) + f(x+k) = n
\]
for all \( x \in \mathbb{R} \), where \( k > 0 \) and \( n \) is a positive integer.
2. **Periodicity of the Function**:
From the given condition, we can derive that:
\[
f(x) + f(x+k) = n \quad \text{(1)}
\]
Replacing \( x \) with \( x+k \) in (1):
\[
f(x+k) + f(x+2k) = n \quad \text{(2)}
\]
Replacing \( x \) with \( x+2k \) in (1):
\[
f(x+2k) + f(x+3k) = n \quad \text{(3)}
\]
Continuing this process, we can observe that the function \( f \) is periodic with period \( 2k \). Therefore, we can express \( f(x) \) in terms of its values over one period.
3. **Integrals**:
We define the integrals:
\[
I_1 = \int_0^{4nk} f(x) \, dx
\]
\[
I_2 = \int_{-k}^{3k} f(x) \, dx
\]
4. **Calculating \( I_1 \)**:
Since \( f \) is periodic with period \( 2k \), we can break down \( I_1 \):
\[
I_1 = \int_0^{4nk} f(x) \, dx = 2n \int_0^{2k} f(x) \, dx
\]
This is because \( 4nk \) can be divided into two full periods of \( 2k \).
5. **Calculating \( I_2 \)**:
For \( I_2 \):
\[
I_2 = \int_{-k}^{3k} f(x) \, dx
\]
We can split this integral into two parts:
\[
I_2 = \int_{-k}^{0} f(x) \, dx + \int_{0}^{2k} f(x) \, dx + \int_{2k}^{3k} f(x) \, dx
\]
The integral from \( 2k \) to \( 3k \) can be transformed using the periodicity:
\[
\int_{2k}^{3k} f(x) \, dx = \int_{0}^{k} f(x) \, dx
\]
Thus, we have:
\[
I_2 = \int_{-k}^{0} f(x) \, dx + \int_{0}^{2k} f(x) \, dx + \int_{0}^{k} f(x) \, dx
\]
The integral from \( -k \) to \( 0 \) can also be transformed using periodicity:
\[
\int_{-k}^{0} f(x) \, dx = \int_{k}^{0} f(x) \, dx = \int_{0}^{k} f(x) \, dx
\]
Therefore:
\[
I_2 = 2 \int_{0}^{k} f(x) \, dx + \int_{0}^{2k} f(x) \, dx
\]
6. **Final Calculation**:
Now, we can express both integrals in terms of \( n \):
- From the periodicity and the original condition, we find:
\[
\int_{0}^{k} f(x) \, dx = \frac{nk}{2}
\]
- Thus:
\[
I_1 = 2n \cdot 2 \cdot \frac{nk}{2} = 2n^2 k
\]
\[
I_2 = 2 \cdot \frac{nk}{2} + 2n \cdot k = 2nk
\]
7. **Conclusion**:
Therefore, we have:
\[
I_1 = 2n^2 k \quad \text{and} \quad I_2 = 2nk
\]
The final result shows that \( I_1 \) and \( I_2 \) are related through their expressions, confirming the periodic nature of \( f \).