Solution (source code)

= Solution

Let $n\geq2$ be even and integrate $f(z)=1/(1+z^n)$ around an upper-half-plane <semicircle> of radius $R>1$ with the real segment traversed from $-R$ to $R$. There are no real <poles>, and the $n/2$ upper-half-plane <poles> are
$$
z_j=e^{i(2j+1)\pi/n},\qquad j=0,\ldots,n/2-1.
$$
Each is simple. Since $z_j^n=-1$,
$$
\operatorname{Res}_{z=z_j}f=\frac1{nz_j^{n-1}}=-\frac{z_j}{n}.
$$
On the <semicircle> the <integral> magnitude is at most $\pi R/(R^n-1)$, which tends to zero. The real <integral> is <absolutely convergent> because its tail is of order $|x|^{-n}$. Thus
$$
\int_{-\infty}^{\infty}\frac{dx}{1+x^n}
=-\frac{2\pi i}{n}\sum_{j=0}^{n/2-1}e^{i(2j+1)\pi/n}.
$$
Evaluate the finite <geometric series>, writing $\theta=\pi/n$:
$$
\sum_{j=0}^{n/2-1}e^{i(2j+1)\theta}
=e^{i\theta}\frac{1-e^{in\theta}}{1-e^{2i\theta}}
=\frac{2e^{i\theta}}{-2ie^{i\theta}\sin\theta}
=\frac{i}{\sin\theta}.
$$
Consequently
$$
\boxed{\int_{-\infty}^{\infty}\frac{dx}{1+x^n}=\frac{2\pi}{n\sin(\pi/n)},\qquad
A_n=\frac{2\pi}{n},\quad B_n=\frac\pi n.}
$$
For $n=2$ this reduces to $\pi$, as a check on the contour orientation and <residue> signs.