Solution (source code)

= Solution

For a <geodesic triangle> with interior angles $\alpha,\beta,\gamma$, the local <Gauss-Bonnet theorem> is
$$
\boxed{\int_TK\,dA=\alpha+\beta+\gamma-\pi},
$$
because its geodesic sides have zero <geodesic curvature>.

Triangulate a closed oriented surface into $F$ geodesic triangles, with $E$ edges and $V$ vertices. Summing the local formula, the angles around each vertex total $2\pi$, so
$$
\int_SK\,dA=2\pi V-\pi F.
$$
Since every triangular face has three edges and every edge belongs to two faces, $3F=2E$. Hence
$$
\int_SK\,dA=2\pi(V-E+F)
=\boxed{2\pi\chi(S)},
$$
which is the global Gauss-Bonnet theorem.

For the sphere $S_r$, the unit normal is $N(p)=p/r$. Its <shape operator> is, up to the conventional sign, $(1/r)I$ on each tangent plane. Both <principal curvature>[principal curvatures] therefore have magnitude $1/r$, and the <Gaussian curvature> is
$$
\boxed{K=\frac1{r^2}}.
$$

An octant has one eighth of the sphere's area:
$$
\operatorname{area}(T)=\frac18(4\pi r^2)=\frac{\pi r^2}{2}.
$$
Thus $\int_TK\,dA=\pi/2$. Its three great-circle sides meet at three right angles, so
$$
\alpha+\beta+\gamma-\pi
=3\frac\pi2-\pi=\frac\pi2.
$$
The two sides of the local Gauss-Bonnet formula agree directly.