Integral top homology of a compact connected surface (source code)

= Integral top homology of a compact connected surface

For a compact connected surface $S$,
$$
H_2(S;\mathbb Z)\cong
\begin{cases}
\mathbb Z,&S\text{ is closed and orientable},\\
0,&S\text{ is nonorientable or has nonempty boundary}.
\end{cases}
$$
In particular, its second integral homology has rank at most one.