\documentclass{article}
\usepackage{amsmath, amssymb,verbatim, amsthm, graphicx}

%exercise environment
\newcounter{exercise}
\setcounter{exercise}{0}
\newenvironment{exercise}{\addtocounter{exercise}{1} \noindent{\bf{Exercise \theexercise.}}}{\vspace{.5cm}}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\perm}{\operatorname{Perm}}

\renewcommand{\empty}{\varnothing}

\textwidth 6.5in
\textheight 9in
\oddsidemargin 0in
\evensidemargin 0in
\headsep -0.5in

\setlength{\parskip}{0.25cm}

\pagenumbering{gobble}

\begin{document}


\noindent{\Large{\textsc{Number Theory \hfill Assignment $n$  \\ Fall 2023 \hfill \'C.\ F.\ Gauss}}}

\large

\vspace{1cm}

\begin{exercise}
Prove that
\[
1 + 2 + 3 + \cdots + n = \frac{n(n+1)}{2}
\]
for all $n \ge 1$.
\end{exercise}

\begin{proof}[Solution.]
If $n$ is even, then for $1 \le k \le n/2$ we may pair $k$ with $n-k+1$ in the sum in question, obtaining
\[
1 + 2 + 3 + \cdots + n  = \frac{n}{2}(k + (n-k+1)) = \frac{n(n+1)}{2},
\]
as claimed.  If $n$ is odd, we may still pair $k$ with $n-k+1$, but only for $1 \le k< \frac{n+1}{2}$.  This leaves the summand $\frac{n+1}{2}$ unpaired, so that in this case we have
\[
1 + 2 + 3 + \cdots + n  = \frac{n-1}{2} (k + (n-k+1))  + \frac{n+1}{2} = \frac{n+1}{2} \left(  n-1  + 1 \right) = \frac{n(n+1)}{2}
\]
once again.
\end{proof}

\end{document}
