Answer
$x^{2n}-x^n+1$.
Work Step by Step
The given expression is
$\Rightarrow (x^{3n}+1)\div (x^n+1)$
Write the dividend in descending powers of $x$.
$\Rightarrow (x^{3n}+0x^{2n}+0x^n+1)\div (x^n+1)$
$\begin{matrix}
& x^{2n} & -x^n &+1 & & \leftarrow &Quotient\\
&-- &-- &--&--& \\
x^n+1) &x^{3n}&+0x^{2n}&+0x^{n} &+1 \\
& x^{3n} & +x^{2n} & & & \leftarrow &x^{2n}(x^n+1) \\
& -- & -- & & & \leftarrow &subtract \\
& 0 & -x^{2n} & +0x^n & & \\
& & -x^{2n} & -x ^n & & \leftarrow & -x^{n}(x^n+1) \\
& & -- & -- & & \leftarrow & subtract \\
& & 0&x^n &+1 & \\
& & & x^n&+1 & \leftarrow & 1(x^n+1)) \\
& & & -- & -- & \leftarrow & subtract \\
& & & 0 & 0 & \leftarrow & Remainder
\end{matrix}$
The quotient $x^{2n}-x^n+1$. $x^n+1$ is a factor of the dividend $x^{3n}+1$ because the remainder is zero.
The solution is
$=x^{2n}-x^n+1$.