<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass[12pt,reqno]{article}

\usepackage[usenames]{color}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amscd}
\usepackage{graphicx}

\usepackage[colorlinks=true,
linkcolor=webgreen,
filecolor=webbrown,
citecolor=webgreen]{hyperref}

\definecolor{webgreen}{rgb}{0,.5,0}
\definecolor{webbrown}{rgb}{.6,0,0}

\usepackage{color}
\usepackage{fullpage}
\usepackage{float}

\usepackage{psfig}
\usepackage{graphics}
\usepackage{latexsym}
\usepackage{epsf}
\usepackage{breakurl}

\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{.1in}
\setlength{\evensidemargin}{.1in}
\setlength{\topmargin}{-.1in}
\setlength{\textheight}{8.4in}

\newcommand{\seqnum}[1]{\href{https://oeis.org/#1}{\rm \underline{#1}}}
\usepackage{diagbox}
\usepackage{caption}

\begin{document}

\begin{center}
\includegraphics[width=4in]{logo129.eps}
\end{center}


\newtheorem{thm}{Theorem}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{conj}[thm]{Conjecture}

\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}
\newtheorem{example}[thm]{Example}
\newtheorem{remark}[thm]{Remark}
\newtheorem{question}[thm]{Question}

\newcommand{\N}{\mathbb{N}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\bigO}{\mathcal{O}}
\newcommand{\floor}[1]{\lfloor #1 \rfloor} % floor
\newcommand{\Floor}[1]{\Big\lfloor #1 \Big\rfloor} % \Big floor
\newcommand{\FLoor}[1]{\bigg\lfloor #1 \bigg\rfloor} % \bigg floor
\newcommand{\ceil}[1]{\lceil #1 \rceil}
\newcommand{\Ceil}[1]{\Big\lceil #1 \Big\rceil} % \Big ceiling
\newcommand{\CEil}[1]{\bigg\lceil #1 \bigg\rceil} % \bigg ceiling
\newcommand{\fpf}[2]{\bigg\{\frac{#1}{#2}\bigg\}} % \bigg fractional part with two inputs: numerator and denominator
\newcommand{\flrf}[2]{\bigg\lfloor\frac{#1}{#2}\bigg\rfloor} %floor of a fraction
\newcommand{\clf}[2]{\bigg\lceil\frac{#1}{#2}\bigg\rceil} %ceiling of a fraction
\newcommand{\divs}{d} % num of divisors fn
\newcommand{\Jacr}{r} % Jacobi's r_2 function
\newcommand{\DirichletD}{D}
\newcommand{\GaussC}{C}
\newcommand{\Ellip}{E}
\newcommand{\dx}{\mathrm{d}x}
\newcommand{\Fseq}{\mathcal{F}} % floor sequence
\newcommand{\Cseq}{\mathcal{C}} % ceiling sequence
\newcommand{\Rseq}{\mathcal{R}} % rounding sequence
\newcommand{\Num}{\mathcal{N}} % function which counts terms in a shifted sequence which are r mod m
\newcommand{\reallydivs}{\dagger} 
\newcommand{\nintp}[1]{R'( #1 )}
\newcommand{\nint}[1]{\lfloor#1\rceil} % nint function
\newcommand{\Nint}[1]{\Big\lfloor#1\Big\rceil} % \Big nint function
\newcommand{\NInt}[1]{\bigg\lfloor#1\bigg\rceil} % \bigg nint function

\makeatletter % this cleans up typesetting mod in a congruence
\let\@@pmod\pmod
\DeclareRobustCommand{\pmod}{\@ifstar\@pmods\@@pmod}
\def\@pmods#1{\mkern4mu({\operator@font mod}\mkern 6mu#1)}
\makeatother

\begin{center}
\vskip 1cm{\LARGE\bf 
On Residues of Rounded Shifted Fractions \\
\vskip .1in
with a Common Numerator
}
\vskip 1cm
\large
{Nicholas Dent}\\
Department of Mathematics\\
Boston University Academy\\
Boston, MA 02215\\
USA\\
\href{mailto:ndent@bu.edu}{\tt ndent@bu.edu}\\
\ \\
{Caleb M.\ Shor}\\
Department of Mathematics\\
Western New England University\\
Springfield, MA 01119\\
USA\\
\href{mailto:cshor@wne.edu}{\tt cshor@wne.edu}\\
\end{center}

\vskip .2 in

\begin{abstract}
    The proportion of integers 
    \[\floor{n/1}, \floor{n/2}, \dots, \floor{n/n}\]
    that are odd is asymptotically $\log2$. If instead of the floor function, one uses the nearest-integer function, the proportion drops to $\pi/2-1$. In this work, we prove these facts and, more generally, give an integral formula for the proportion of 
    \[\floor{(n-\nu)/1+\alpha},\, \floor{(n-\nu)/2+\alpha},\, \dots,\, \floor{(n-\nu)/n+\alpha}\]
    that are congruent to $r$ modulo $m$. We conclude by linking this problem to the Dirichlet divisor and Gauss circle problems, and counting lattice points in other quadratic regions.
\end{abstract}

\section{Introduction}
For $\N$ the set of positive integers and $n\in\N$, consider the integer sequence 
\begin{equation}\label{seq:intro}
    \FLoor{\frac{n}{1}}, \FLoor{\frac{n}{2}}, \FLoor{\frac{n}{3}}, \dots, \FLoor{\frac{n}{n}},
\end{equation}
where $\floor{x}$ denotes the usual floor function for real $x$. Among the $n$ integers in this sequence, how many are odd?

Let's start with some data. For $n=5$, the sequence is
\[
    \FLoor{\frac{5}{1}}, \FLoor{\frac{5}{2}}, \FLoor{\frac{5}{3}}, \FLoor{\frac{5}{4}}, \FLoor{\frac{5}{5}} = 5, 2, 1, 1, 1,
\] which contains 4 odd numbers. For $n=10$, the sequence is $10, 5, 3, 2, 2, 1, 1, 1, 1, 1$, which contains 7 odd numbers. 
For $n=13$, there are 9 odd numbers. 

For any $n$, terms in the second half of Seq.~\eqref{seq:intro} are all 1. Thus, the proportion of odd terms is at least $50\%$. But how much bigger will it be? Does the proportion converge to a particular number as $n$ gets large? And what happens if we replace the floor function with the ceiling function? Or if we round to the nearest-integer?

In order to address these questions, we define sequences $(\Fseq_n)_{n\ge1}$, $(\Cseq_n)_{n\ge1}$, and $(\Rseq_n)_{n\ge1}$ by
\begin{align*}
    \Fseq_n &amp;= \#\{k\in\Z : 1\le k\le n,\, \floor{n/k}\text{ is odd}\},\\
    \Cseq_n &amp;= \#\{k\in\Z : 1\le k\le n,\, \ceil{n/k}\text{ is odd}\},\\
    \Rseq_n &amp;= \#\{k\in\Z : 1\le k\le n,\, \nint{n/k}\text{ is odd}\},
\end{align*}
where $\ceil{x}$ denotes the ceiling function and $\nint{x}$ the nearest-integer rounding function. (In this work, we use the convention for nearest-integer rounding to round half-integers up. We consider other conventions in Remark~\ref{rmk:nint-half-integers}.)  The sequences $(\Fseq_n)_{n\ge1}$, $(\Cseq_n)_{n\ge1}$, and $(\Rseq_n)_{n\ge1}$ appear in The On-Line Encyclopedia of Integer Sequences \cite{oeis} as, respectively, sequences \seqnum{A059851}, \seqnum{A330926}, and \seqnum{A363341}. 


\begin{figure}[H]
    \centering
    \begin{tabular}{c|rrrrrrrrrrrrrrrrrrrr}
    $n$ &amp; 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 &amp; 6 &amp; 7 &amp; 8 &amp; 9 &amp; 10 &amp; 11 &amp; 12 &amp; 13 &amp; 14 &amp; 15 &amp; 16 &amp; 17 &amp; 18 &amp; 19 &amp; 20 \\ \hline 
    $\Fseq_n$ &amp; 1 &amp; 1 &amp; 3 &amp; 2 &amp; 4 &amp; 4 &amp; 6 &amp; 4 &amp; 7 &amp; 7 &amp; 9 &amp; 7 &amp; 9 &amp; 9 &amp; 13 &amp; 10 &amp; 12 &amp; 12 &amp; 14 &amp; 12 \\ 
    $\Cseq_n$ &amp; 1 &amp; 1 &amp; 2 &amp; 1 &amp; 3 &amp; 2 &amp; 3 &amp; 2 &amp; 5 &amp; 3 &amp; 4 &amp; 3 &amp; 6 &amp; 5 &amp; 6 &amp; 3 &amp; 7 &amp; 6 &amp; 7 &amp; 6 \\ 
    $\Rseq_n$ &amp; 1 &amp; 1 &amp; 2 &amp; 2 &amp; 4 &amp; 3 &amp; 4 &amp; 4 &amp; 6 &amp; 7 &amp; 6 &amp; 5 &amp; 9 &amp; 8 &amp; 9 &amp; 9 &amp; 10 &amp; 10 &amp; 11 &amp; 12
\end{tabular}
    \caption{Values of $\Fseq_n$, $\Cseq_n$, $\Rseq_n$ for $1\le n\le 20$.}
    \label{fig:first-20-terms}
\end{figure}


\begin{figure}[H]
    \centering
    \includegraphics[width=.6\textwidth]{first-three-sequences.eps}
    \caption{Plots of $y=\Fseq_n$ (red, top-most), $y=\Rseq_n$ (blue, middle), and $y=\Cseq_n$ (black, bottom-most), for $1\le n\le 1000$.}
    \label{fig:first-three-sequences}
\end{figure}

From the data generated above, we have $\Fseq_5=4$, $\Fseq_{10}=7$, and $\Fseq_{13}=9$. The first 20 terms of each sequence are in Figure~\ref{fig:first-20-terms}. Plots of the first 1000 terms of each sequence appear in Figure~\ref{fig:first-three-sequences}.

The plots in Figure~\ref{fig:first-three-sequences} suggest that each sequence is roughly linear. We will see that this is true asymptotically, with slopes given by
\[
    \lim\limits_{n\to\infty}\dfrac{\Fseq_n}{n}=\log2,
    \quad
    \lim\limits_{n\to\infty}\dfrac{\Cseq_n}{n}=1-\log2,
    \quad\text{ and } 
    \lim\limits_{n\to\infty}\dfrac{\Rseq_n}{n}=\frac{\pi}{2}-1.
\]
In particular, since $\log2\approx 0.693147$, the proportion of odd terms in Seq.~\eqref{seq:intro} is asymptotically approximately $69.3\%$.

Our results follow from two classical results in analytic number theory about counting lattice points in the plane: the \textit{Dirichlet divisor problem} (Theorem~\ref{thm:dirichlet}), which involves counting lattice points beneath the hyperbola $xy=n$; and the \textit{Gauss circle problem} (Theorem~\ref{thm:gauss}), which involves counting lattice points within a circle of radius $\sqrt{n}$.

These classical results lead to geometric interpretations for our sequences. In Proposition~\ref{prop:F_n-Dirichlet}, we find that $\Fseq_n$ is the difference of the numbers of lattice points in two hyperbolic regions in the plane. In Proposition~\ref{prop:gauss-R_n}, we show that the number of lattice points contained in a circle of radius $\sqrt{2n}$ is equal to $4\Rseq_n+4n+1$.

We now consider more general sequences. Given that $\nint{x}=\floor{x+1/2}$, we can think of the nearest-integer rounding function as the usual floor function shifted by $1/2$. If we replace this $1/2$ with an arbitrary real number $\alpha$ and also incorporate a real number $\nu$ to offset the numerator $n$, we obtain an \textit{$\alpha$-shifted, $\nu$-offset, floor sequence of length $n$}
\begin{equation}\label{seq:alpha-shift-intro}
    \FLoor{\frac{n-\nu}{1}+\alpha}, 
    \FLoor{\frac{n-\nu}{2}+\alpha}, 
    \dots, 
    \FLoor{\frac{n-\nu}{n}+\alpha}.
\end{equation}
As before, we can ask about the number of odd terms in such a sequence. With an answer to that, we can then find $\alpha$ and $\nu$ for which (asymptotically) half of these integers are odd and half are even. We show in Section~\ref{subsec:parity} that there is a unique value for $\alpha\in[0,1]$, independent of $\nu$, for which this occurs, and numerically approximate it.

Another problem, given integers $r$ and $m$, is to compute $\Num_{n,\alpha,\nu,r,m}$, the number of integers in Seq.~\eqref{seq:alpha-shift-intro} that are congruent to $r$ modulo $m$. Our main result is Theorem~\ref{thm:N_m-asymp}, which states that for any $m\in\N$ and $\alpha\in[0,1)$,
\begin{equation}\label{eqn:asmyp-1-mod-m}
    \Num_{n,\alpha,\nu,1,m} = \frac{-\alpha n}{1-\alpha}+
    n\int\limits_0^1 \frac{(1-x)x^{-\alpha}}{1-x^m}\dx + \bigO\big(\sqrt{n}\big)
\end{equation}
and, for $2\le r\le m$, 
\begin{equation}\label{eqn:asmyp-r-mod-m}
    \Num_{n,\alpha,\nu,r,m} = n\int\limits_0^1 \frac{(1-x)x^{r-1-\alpha}}{1-x^m}\dx + \bigO\big(\sqrt{n}\big).
\end{equation}

Finally, we look more closely at connections between the number of integers in a certain congruence class in an $\alpha$-shifted, $\nu$-offset, floor sequence of length $n$ and the number of lattice points in a certain region of the plane. We demonstrate the connections by obtaining formulas in terms of these counts for the number of lattice points in the following elliptical regions: $x^2+y^2\le n$; $x^2+xy+y^2\le n$; and $x^2+2y^2\le n$, each for any $n\in\N$. Our results here follow from the theory of binary quadratic forms. In particular, counting lattice points in the elliptical region $x^2+xy+y^2\le n$ gives us a way to count the number of lattice points in a hexagonal lattice contained in a disc, which we describe in Corollary~\ref{cor:hex-lattice-points}.

\subsection{Motivation}
This paper grew out of a problem in a recent paper by Shor \cite[Sec.\ 5.2]{Shor23} on numerical semigroups. Obtaining an asymptotic formula for the number of reflective numerical semigroups with a given Frobenius number amounted to finding an asymptotic formula for $(\Fseq_n)_{n\ge1}$.

\subsection{Organization}
In Section~\ref{sec:F_n and C_n}, we find exact and asymptotic formulas for $\Fseq_n$ and $\Cseq_n$. In Section~\ref{sec:Rseq_n}, we do the same for $\Rseq_n$. Our main result appears in Section~\ref{sec:generalized}, where we find exact (Theorem~\ref{thm:N_m-asymp}) and asymptotic (Corollary~\ref{cor:N_m-slope}) formulas for $\Num_{n,\alpha,\nu,r,m}$, generalizing the results of the previous sections. Finally, in Section~\ref{sec:applications}, we have two tasks. First, we compute the (unique) shift $\alpha=\alpha_0$ for which (asymptotically) the $\alpha$-shifted, $\nu$-offset, floor sequence of length $n$ contains as many odd terms as even terms. Second, we determine the number of lattice points in certain elliptical regions of the plane in terms of the sequences $\Num_{n,\alpha,\nu,r,m}$.

\subsection{A question for further study}\label{sec:question}
Our error term for $\Num_{n,\alpha,\nu,r,m}$, (Eqs.~\eqref{eqn:asmyp-1-mod-m} and \eqref{eqn:asmyp-r-mod-m}, from Theorem~\ref{thm:N_m-asymp}) which is  $\bigO\big(\sqrt{n}\big)$, can almost certainly be improved upon.

The sequences $\Fseq_n$ and $\Rseq_n$ are special cases of $\Num_{n,\alpha,\nu,r,m}$. The error term for $\Fseq_n$ is the same as the error term for the Dirichlet divisor problem, and the error term for $\Rseq_n$ is the same as the error term for the Gauss circle problem. At present, the best error bounds known for these two problems are the same: $\bigO\big(n^{131/416}\big)$, as shown by Huxley \cite{Huxley2002}. It would be interesting to see if that error bound holds for $\Num_{n,\alpha,nu,r,m}$ in general, or at least for other particular parameter values.

\section{The floor and ceiling sequences}\label{sec:F_n and C_n}
The quantities $\Fseq_n$ and $\Cseq_n$ are very closely related, so we investigate both of them in this section.

\subsection{The floor sequence}
As was described in the introduction, the number of odd integers in the floor sequence 
\begin{equation}\label{seq:floor}
    \FLoor{\frac{n}{1}}, \FLoor{\frac{n}{2}}, \dots, \FLoor{\frac{n}{n}}
\end{equation}
is $\Fseq_n$. In this subsection, we find an exact formula for $\Fseq_n$. Then, with that formula and the solution to Dirichlet's divisor problem, we obtain an asymptotic formula for $\Fseq_n$.

We begin by counting the number of integers in Seq.~\eqref{seq:floor} that are greater than or equal to a given integer.
\begin{lem}\label{lem:consec_flr}
    Fix $n\in\N$. For $k\in \N$,  Seq.~\eqref{seq:floor} contains $\floor{n/k}$ terms that are greater than or equal to $k$.
\end{lem} 

\begin{proof}
Via the division algorithm, there are $q,r\in \Z$ for which $n=kq+r$ with $0\leq r&lt; k$. Then $\floor{n/k}=q$. Our approach is to show that the first $q$ terms in Seq.~\eqref{seq:floor} are greater than or equal to $k$. 

Note that 
\[
    \flrf{n}{q} 
    = \flrf{kq+r}{q} 
    = \FLoor{k+\frac{r}{q}}\ge k.
\] 
Now consider an arbitrary term $\floor{n/d}$ in Seq.~\eqref{seq:floor}. Then $1\leq d\leq n$. If $d &lt; q$, then $n/d&gt;n/q$ and hence $\floor{n/d}\ge\floor{n/q}\ge k$. On the other hand, if $d &gt; q$, then $d\ge q+1$. This means $kd \ge k(q+1) &gt; n$ and therefore $k&gt;n/d\geq \floor{n/d}$. We have already shown that $\floor{n/d}\geq k$ if $d=q$. We conclude that $\floor{n/d}\geq k$ if and only if $d \in \{1,2,\dots ,q\}$.
\end{proof} 

We can now find an exact formula for $\Fseq_n$.
\begin{prop}\label{prop:floor_seq}
    For $n\in\N$, 
    \[
        \Fseq_n
        =\sum\limits_{d=1}^n\FLoor{\frac{n}{d}}(-1)^{d+1}.
    \]
\end{prop}
\begin{proof}
We wish to count the number of odd terms in Seq.~\eqref{seq:floor}. Here we can use Lemma~\ref{lem:consec_flr} to see that for a given $k$ there are $\floor{n/k}$ terms whose value is at least $k$, and thus $\floor{n/k}-\floor{n/(k+1)}$ terms whose value is exactly $k$. To compute $\Fseq_n$, we sum for all odd $k$. We find
    \[
        \Fseq_n 
        =\sum\limits_{\substack{1\le k\leq n \\ k \text{ odd}}} \Bigg(\flrf{n}{k}-\flrf{n}{k+1}\Bigg)
        =\sum\limits_{d=1}^n\FLoor{\frac{n}{d}}(-1)^{d+1},
    \]
as desired.
\end{proof}

With this exact formula, we now work toward an asymptotic formula for $\Fseq_n$. For $\tau(n)$ the number of positive divisors of a positive integer $n$, consider the \textit{divisor summatory function} 
    \[
        \DirichletD(x)=\sum\limits_{m\le x}\tau(m),
    \]
where the summation is taken over positive integers $m$. We have the following for all $n\in\N$:
\[
    \DirichletD(n)
    = \sum\limits_{m=1}^n\tau(m)
    = \sum\limits_{m=1}^n\sum\limits_{d\mid m}1 
    = \sum\limits_{d=1}^n\FLoor{\frac{n}{d}}.
\]
Viewed this way, we see that $\DirichletD(n)$ is equal to the number of lattice points in the interior and boundary of the region in the $xy$-plane bounded by the graphs of $x=1$, $y=1$, and the hyperbola $xy=n$.

\begin{cor}\label{cor:Fn=D(n)-2D(n/2)}
    For all $n\in\N$, we have $\Fseq_n=\DirichletD(n)-2\DirichletD(n/2)$.
\end{cor}
\begin{proof}
    We manipulate the formula for $\Fseq_n$ obtained in Proposition~\ref{prop:floor_seq}, considering odd and even $d$ (with $1\le d\le n$) separately:
    \begin{align*}
        \Fseq_n
        &amp;=\sum\limits_{d\text{ odd}} \FLoor{\frac{n}{d}}-\sum\limits_{d\text{ even}} \FLoor{\frac{n}{d}}\\
        &amp;=\sum\limits_{d\text{ odd}} \FLoor{\frac{n}{d}}-\sum\limits_{d\text{ even}} \FLoor{\frac{n}{d}}+\sum\limits_{d\text{ even}} \FLoor{\frac{n}{d}}-\sum\limits_{d\text{ even}} \FLoor{\frac{n}{d}}\\
        &amp;=\sum\limits_{d=1}^n\FLoor{\frac{n}{d}} - 2\sum\limits_{b=1}^{\floor{n/2}}\FLoor{\frac{n}{2b}}\\
        &amp;=\sum\limits_{d=1}^n\FLoor{\frac{n}{d}} - 2\sum\limits_{b=1}^{\floor{n/2}}\FLoor{\frac{n/2}{b}}.
    \end{align*}
    The result follows.
\end{proof}

The geometric interpretation for $\DirichletD(n)$ gives a geometric interpretation for $\Fseq_n$. For $n\in\N$, we define two regions. Let $H_{1,n}$ be the hyperbolic region in the $xy$-plane with $x,y\ge1$ bounded by the graphs of the hyperbola $xy=n$ and the hyperbola $xy=n/2$. Let $H_{2,n}$ be the region in the $xy$-plane bounded by the graphs of $x=1$, $y=1$, and the hyperbola $xy=n/2$. Then $\DirichletD(n)$ is equal to the number of lattice points in $H_{1,n}\cup H_{2,n}$, and $\DirichletD(n/2)$ is equal to the number of lattice points in $H_{2,n}$.

\begin{prop}\label{prop:F_n-Dirichlet}
    For all $n\in\N$, the number of lattice points in $H_{1,n}$ minus the number of lattice points in $H_{2,n}$ is equal to $\Fseq_n$. For $H_{1,n}$, we include all points on the boundary except for those on the boundary curve $xy=n/2$. For $H_{2,n}$, we include all points on the boundary.
\end{prop}
\begin{figure}[H]
    \centering
    \includegraphics[scale=.7]{hyperbola-points.eps}
    \caption{For $n=17$, the graphs of $xy=17$ and $xy=17/2$ along with lattice points in the hyperbolic regions $H_{1,17}$ (circles) and in $H_{2,17}$ (stars).}
    \label{fig:hyperbola-F_n}
\end{figure}
\begin{example}
    To illustrate Proposition~\ref{prop:F_n-Dirichlet}, we have drawn the regions $H_{1,n}$ and $H_{2,n}$ for $n=17$ in Figure~\ref{fig:hyperbola-F_n}. Since $H_{1,17}$ contains 32 points and $H_{2,17}$ contains 20 points, we find $\Fseq_{17}=32-20=12$.
\end{example}

The following theorem of Dirichlet gives an asymptotic formula for $\DirichletD(x)$. (For details, see, e.g., Apostol's textbook \cite[Theorem 3.3]{Apostol1976}. Later in this paper, we give a modified version of the proof of this theorem. See Proposition~\ref{prop:sum-of-floors-to-sum-of-fractions}.)
\begin{thm}\label{thm:dirichlet}
    For all $x\ge1$, 
    \[
        \DirichletD(x)
        =x\log{x}+(2\gamma-1)x+\bigO(\sqrt{x}),
    \]
    where $\gamma = \lim\limits_{n\to\infty}\bigg(-\log{n}+\sum\limits_{k=1}^n 1/k\bigg)\approx 0.577216$ is the Euler-Mascheroni constant.
\end{thm}

Finally, let $F(x)=\DirichletD(x)-2\DirichletD(x/2)$. Then $\Fseq_n=F(n)$ and, via Theorem~\ref{thm:dirichlet} we have $F(x)=x\log2+\bigO(\sqrt{x})$. Restricting to integers $n$, we get an asymptotic result for $\Fseq_n$.

\begin{prop}\label{prop:floor_seq_asymp}
    Let $n\in\N$. Then
    $\Fseq_n 
        = n\log2+\bigO\big(\sqrt{n}\big)$ and $\lim\limits_{n\to\infty}\frac{1}{n}\Fseq_n=\log{2}\approx0.693147$.
\end{prop}

\begin{remark}\label{rmk:Fn-improved}
    The error bound for $\DirichletD(x)$ in Theorem~\ref{thm:dirichlet} has been improved over the years since Dirichlet's original result. The \textit{Dirichlet divisor problem} is to give the best error term. The best error bound currently known is $\bigO\big(x^{131/416}\big)$, due to Huxley \cite{Huxley2002}. This gives us the following improved error bound for $\Fseq_n$:
    \[\Fseq_n = n \log{2} + \bigO\big(n^{131/416}\big).\]
\end{remark}

\subsection{The ceiling sequence}
As was mentioned in the introduction, for $n\in\N$, the number of odd integers in the ceiling sequence 
\begin{equation}\label{seq:ceiling}
    \CEil{\frac{n}{1}}, \CEil{\frac{n}{2}}, \dots, \CEil{\frac{n}{n}}
\end{equation}
is $\Cseq_n$. In this subsection, we find a relation between $\Cseq_n$ and $\Fseq_{n-1}$ which, along with results from the previous subsection, leads to exact and asymptotic formulas for $\Cseq_n$. 

\begin{prop}\label{prop:ceiling_seq}
    For $n\in\N$,
    \[
        \Cseq_n
        = n-\Fseq_{n-1} = \sum\limits_{d=2}^n \FLoor{\frac{n}{d}}(-1)^d.
    \]
\end{prop}
\begin{proof}
We begin by showing that $\ceil{n/k}=\floor{(n-1)/k}+1$ for all $k\in\N$. Taking the same approach as with Lemma~\ref{lem:consec_flr}, via the division algorithm, there are $q,r\in \Z$ for which $n=kq+r$ with $0\leq r&lt; k$. 

If $r=0$, then $n/k=q$ and so $\ceil{n/k}=\ceil{q}=q$. We also have
\[
    \flrf{n-1}{k}=\FLoor{\frac{n}{k}-\frac{1}{k}}
    =\FLoor{q-\frac{1}{k}}
    =q-1.
    \]
In this case, $\ceil{n/k}=\floor{(n-1)/k}+1$.

If $r\ne0$, then $1\le r&lt;k$. We have 
\[
    \clf{n}{k}
    =\clf{kq+r}{k}
    =\CEil{q+\frac{r}{k}}
    = q+1.
\] 
and
\[
    \flrf{n-1}{k}
    =\flrf{kq+r-1}{k}
    =\FLoor{q+\frac{r-1}{k}}
    =q.
\] 
In this case, $\ceil{n/k}=\floor{(n-1)/k}+1$.

\sloppy Since we have $\ceil{n/k}=\floor{(n-1)/k}+1$ for all $k\in\N$, for each pair of integers $(\ceil{n/k},\floor{(n-1)/k})$, exactly one integer is odd. Hence, the total number of odd integers in the two sequences 
\[
    \CEil{\frac{n}{1}},\CEil{\frac{n}{2}},\dots,\CEil{\frac{n}{n}}
    \text{ and }
    \FLoor{\frac{n-1}{1}},\FLoor{\frac{n-1}{2}},\dots,\FLoor{\frac{n-1}{n}}
\] 
is $n$. The number of odd integers in the first sequence is $\Cseq_n$. Since the last term in the second sequence is $\floor{(n-1)/n}=0$, the number of odd integers in the second sequence is $\Fseq_{n-1}$. This means $\Fseq_{n-1}+\Cseq_n=n$. The stated result then follows from Proposition~\ref{prop:floor_seq}.
\end{proof} 

We immediately obtain the following asymptotic formula for $\Cseq_n$.

\begin{cor}\label{cor:ceiling_seq_asymp} 
    Let $n\in\N$. Then $\Cseq_n
        = (1-\log2)n+\bigO\big(\sqrt{n}\big)$
and $
        \lim\limits_{n\to\infty}\frac{1}{n}\Cseq_n
        =1-\log2 \approx 0.306853$.
\end{cor}
\begin{proof}
    Combining Proposition~\ref{prop:ceiling_seq} with the asymptotic formula for $\Fseq_n$ in Proposition~\ref{prop:floor_seq_asymp}, we find 
    \[
        \Cseq_n 
        = n - \Fseq_{n-1} 
        = n - (n-1)\log2 + \bigO\big(\sqrt{n-1}\big) 
        = n-n\log2 + \bigO\big(\sqrt{n}\big).
    \]
    The limit result follows.
\end{proof}
\begin{remark}\label{rmk:an-and-bn}
    Alternatively, if we just want the asymptotic formula for $\Cseq_n$, we can get it via the asymptotic formula for $\Fseq_n$ (Proposition~\ref{prop:floor_seq_asymp}) and the following lemma.
    
    \begin{lem}\label{lem:num_divisors_of_n}
        For $n\in\N$, the number of positive divisors of $n$ is at most $2\sqrt{n}$.
    \end{lem}
    \begin{proof}
        Suppose $n=de$ for positive integers $d\le e$. Then $1\le d\le \sqrt{n}$. It follows that there are at most $\sqrt{n}$ pairs of divisors $d,e$, and thus at most $2\sqrt{n}$ positive divisors of $n$.
    \end{proof}

    For any real number $x$, if $x$ is an integer then $\ceil{x}=\floor{x}$, and otherwise $\ceil{x}=\floor{x}+1$. Taking $x=n/k$, this means 
    \[
        \ceil{n/k} = \begin{cases} 
            \floor{n/k}, &amp; \text{if $k\mid n$};\\ 
            \floor{n/k}+1, &amp; \text{if $k\nmid n$}.
        \end{cases}
    \]
    When $k$ does not divide $n$, exactly one of $\floor{n/k}$ and $\ceil{n/k}$ is odd. When $k$ does divide $n$, then either both $\floor{n/k}$ and $\ceil{n/k}$ are odd, or neither is. Since there are at most $2\sqrt{n}$ divisors $d$ of $n$, we have 
    \[
        \Fseq_n+\Cseq_n \in [\, n-2\sqrt{n},n+2\sqrt{n} \, ].
    \]
    Therefore $\Fseq_n+\Cseq_n = n + \bigO\big(\sqrt{n}\big)$. We conclude that $\Cseq_n=n-\Fseq_n+\bigO\big(\sqrt{n}\big) = (1-\log2)n+\bigO\big(\sqrt{n}\big)$. This gives an alternate proof of Corollary~\ref{cor:ceiling_seq_asymp}.
\end{remark}

Finally, we can use the improved error bound for $\Fseq_n$ (mentioned in Remark~\ref{rmk:Fn-improved}) together with Proposition~\ref{prop:ceiling_seq} to get an improved error bound for $\Cseq_n$ as well:
\[\Cseq_n = (1-\log{2})n+\bigO\big(n^{131/416}\big).\]

\section{The nearest-integer sequence}\label{sec:Rseq_n}
As was mentioned in the introduction, the number of odd integers in the nearest-integer rounding sequence 
\begin{equation}\label{seq:nint-seq}
    \NInt{\frac{n}{1}}, \NInt{\frac{n}{2}}, \dots, \NInt{\frac{n}{n}}
\end{equation}
is $\Rseq_n$. We use the convention that half-integers are rounded up; we consider other conventions in Remark~\ref{rmk:nint-half-integers}. In this subsection, we find an exact formula for $\Rseq_n$. Then, with that formula and the solution to Gauss's circle problem, we obtain an asymptotic formula for $\Rseq_n$.

We first note that $\nint{n/k}=\floor{n/k+1/2}$, and thus Seq.~\eqref{seq:nint-seq} is equal to the sequence \begin{equation}\label{seq:rounding-seq}
    \FLoor{\frac{n}{1}+\frac{1}{2}}, \FLoor{\frac{n}{2}+\frac{1}{2}}, \FLoor{\frac{n}{3}+\frac{1}{2}}, \dots, \FLoor{\frac{n}{n}+\frac{1}{2}}.
\end{equation}

Just as we did in obtaining an exact formula for $\Fseq_n$ (Proposition~\ref{prop:floor_seq}), we begin with a lemma.
\begin{lem}\label{lem:round_count}
    Fix $n\in\N$. For $k\in\N$, let $g(k)$ equal the number of terms in Seq.~\eqref{seq:rounding-seq} that are greater than or equal to $k$. Then $g(1)=n$ and, for $k\ge2$, $g(k)=\floor{2n/(2k-1)}$.
\end{lem} 
\begin{proof}
Consider an arbitrary term $\floor{n/d+1/2}$ in the Seq.~\eqref{seq:rounding-seq}, so that $1\le d\le n$. We first observe that $\floor{n/d+1/2}\ge\floor{n/n+1/2} = 1$. Hence, $g(1)=n$.

Next, for $k\ge2$, we have either $d\le 2n/(2k-1)$ or $d&gt;2n/(2k-1)$. We consider these cases separately. 

If $d\leq 2n/(2k-1)$, then $k-1/2 \leq n/d$ which implies $k \leq n/d+1/2$. Since $k$ is an integer, we take the floor of both sides to find $k \leq\floor{n/d+1/2}$.

If $d&gt;2n/(2k-1)$, then $k-1/2&gt;n/d$, which implies $k &gt; n/d+1/2 \geq \floor{n/d+1/2}$. 

Thus, for $k\ge2$, we have $\floor{n/d+1/2}\geq k$ for $d \in\{1, 2, \dots,\floor{2n/(2k-1)}\}$. Since $\floor{2n/(2k-1)}\le n$, we conclude that $g(k)=\floor{2n/(2k-1)}$.
\end{proof}

With this lemma, we can now find an exact formula for $\Rseq_n$.

\begin{prop}\label{prop:rounding_seq}
    For $n\in\N$,
    \[
        \Rseq_n 
        = -n+\sum\limits_{d=1}^{n}\FLoor{\frac{2n}{2d-1}}(-1)^{d+1}.
    \]
\end{prop}
\begin{proof}
We wish to count the number of odd terms in Seq.~\eqref{seq:nint-seq}. By Lemma~\ref{lem:round_count}, there are $n$ terms that are at least 1, and, for $k\ge2$, there are $\floor{2n/(2k-1)}$ terms that are at least $k$. We can use this to count the number of terms that are equal to a given value.

For $k=1$, there are $n-\floor{2n/3}$ terms that are equal to 1. For $k\ge2$, there are $\floor{2n/(2k-1)}-\floor{2n/(2k+1)}$ terms that are equal to $k$. Summing over odd $k$, we find
\begin{align*}
    \Rseq_n 
    &amp;=n-\FLoor{\frac{2n}{3}}+\sum\limits_{\substack{3\le k\le n \\ k\text{ odd}}}\Bigg(\FLoor{\frac{2n}{2k-1}}-\FLoor{\frac{2n}{2k+1}}\Bigg) \\
    &amp;=-n+\sum\limits_{\substack{1\le k\leq n\\ k\text{ odd}}} \Bigg(\flrf{2n}{2k-1}-\flrf{2n}{2k+1}\Bigg)\\
    &amp;=-n+\sum\limits_{d=1}^n\FLoor{\frac{2n}{2d-1}}(-1)^{d+1},
\end{align*}
which completes the proof.
\end{proof}

We now work toward an asymptotic formula for the summation in $\Rseq_n$ via results of Jacobi and Gauss.

To start, we need some notation. For $n\in\N$, $r\in\Z$, and $m\in\N$, let $\divs_{r,m}(n)$ denote the number of positive divisors of $n$ that are congruent to $r$ modulo $m$. We are interested in values of this function for $m=4$ and $r$ equal to 1 or 3. For example, with $n=45$, we have $\divs_{1,4}(45)=4$ and $\divs_{3,4}(45)=2$ because the positive divisors of 45 are 1, 3, 5, 9, 15, and 45. 


\begin{lem}
    For $n\in\N$,
    \[
        \Rseq_n 
        = -n + \sum\limits_{k=1}^{2n}\big(\divs_{1,4}(k)-\divs_{3,4}(k)\big).
    \]
\end{lem}
\begin{proof}
    Each integer $d$ divides $\floor{2n/d}$ integers in the interval $[1,2n]$. If we want to count the number of divisors that are 1 modulo 4 for all of the integers from 1 to $2n$, we see that 1 is a divisor of $\floor{2n/1}$ terms, 5 is a divisor of $\floor{2n/5}$ terms, 9 is a divisor of $\floor{2n/9}$ terms, and so on. In other words, we get 
    \[
        \sum\limits_{k=1}^{2n}\divs_{1,4}(k)
        =\FLoor{\frac{2n}{1}}+\FLoor{\frac{2n}{5}}+\FLoor{\frac{2n}{9}}+\cdots.
    \] 
    Similarly, if we want to add up the number of divisors that are 3 modulo 4 for all of the integers from 1 to $2n$, we get
    \[
        \sum\limits_{k=1}^{2n}\divs_{3,4}(k)
        =\FLoor{\frac{2n}{3}}+\FLoor{\frac{2n}{7}}+\FLoor{\frac{2n}{11}}+\cdots.
    \]
    Observe that the terms in each of the two above summations are eventually all 0, and thus these are finite sums.
    
    Hence,
    \begin{align*}
        \sum\limits_{d=1}^n\FLoor{\frac{2n}{2d-1}}(-1)^{d+1} 
        &amp;= \FLoor{\frac{2n}{1}}-\FLoor{\frac{2n}{3}}+\FLoor{\frac{2n}{5}}-\FLoor{\frac{2n}{7}}+\cdots+(-1)^{n+1}\FLoor{\frac{2n}{2n-1}} \\
        &amp;= \sum\limits_{k=1}^{2n}\big(\divs_{1,4}(k)-\divs_{3,4}(k)\big).
    \end{align*}
    The stated result then follows from the formula for $\Rseq_n$ in Proposition~\ref{prop:rounding_seq}.
\end{proof}

Next, let $\Jacr_2(n)=\#\{(a,b)\in\Z^2 : a^2+b^2=n\}$, the number of representations of $n$ as a sum of two integer squares. For example, still with $n=45$, we find $\Jacr_2(45)=8$ because
\[
    45=(\pm3)^2+(\pm6)^2=(\pm6)^2+(\pm3)^2,
\] 
for a total of 8 combinations. Jacobi's two-square theorem relates $\Jacr_2(n)$ to the number of divisors of $n$ that are 1 modulo 4 and that are 3 modulo 4.

\begin{thm}[Jacobi's two-square theorem]\label{thm:jacobi}
    For $n\in\N$, the number of representations of $n$ as a sum of integer squares is $\Jacr_2(n)=4(\divs_{1,4}(n)-\divs_{3,4}(n))$.
\end{thm}

Jacobi proved this theorem, along with theorems about the number of representations of $n$ using four squares, using six squares, and using eight squares, in 1829 with the use of elliptic theta functions. (See Grosswald \cite{Grosswald1985}.) For another approach, one can use the theory of binary quadratic forms. (In Section~\ref{sec:applications}, we use results about binary quadratic forms. See, e.g., Dickson \cite{Dickson1958}.)

One may also prove Theorem~\ref{thm:jacobi} in the context of the Gaussian integers, which is the ring 
\[
    \Z[i]=\{a+bi : a,bi \in\Z,\, i^2=-1\}.
\]
The norm of the Gaussian integer $a+bi$ is $a^2+b^2$. It follows that $\Jacr_2(n)$ is equal to the number of Gaussian integers with norm equal to a given positive integer $n$. With an understanding of what the prime elements of $\Z[i]$ are, along with the fact that $\Z[i]$ is a unique factorization domain, one may prove Theorem~\ref{thm:jacobi}. (For details, see, e.g., Hardy \&amp; Wright \cite[Theorem 278]{HardyWright1979} or a wonderful video on the 3Blue1Brown channel on YouTube \cite{3b1b-pi-prime-regularities}.)

Visualizing $\Z[i]$ as a lattice in the complex plane (with $a+bi\in\Z[i]$ corresponding to the point $(a,b)$ in the plane), Jacobi's two-square theorem says that the number of lattice points on a circle of radius $\sqrt{n}$ centered at the origin is $4(\divs_{1,4}(n)-\divs_{3,4}(n))$. In general, the point $(a,b)$ is on a circle of radius $\sqrt{a^2+b^2}$ centered at the origin. Thus, adding the numbers of points on circles of radii $\sqrt{1}, \sqrt{2},\dots,\sqrt{2n}$ gives us the total number of lattice points different from the origin in the interior or on the boundary of a circle of radius $\sqrt{2n}$ centered at the origin. Back to our formula for $\Rseq_n$, we now have
\begin{equation}\label{eqn:Rseq_n-circle}
    \Rseq_n 
    = -n + (1/4)\cdot \#\{(a,b)\in\Z^2 : 0&lt;a^2+b^2\le 2n\}.
\end{equation}

Let $\GaussC(x)$ denote the number of lattice points in the interior or on the boundary of a circle of radius $\sqrt{x}$ centered at the origin. Via Eq.~\eqref{eqn:Rseq_n-circle}, we can calculate $\GaussC(2n)$ in terms of $\Rseq_n$.

\begin{prop}\label{prop:gauss-R_n}
    For all $n\in\N$, the number of lattice points within a circle of radius $\sqrt{2n}$ centered at the origin is $4\Rseq_n+4n+1$. That is, we have $\GaussC(2n)=4\Rseq_n+4n+1$.
\end{prop}

\begin{figure}[H]
    \centering
    \includegraphics[scale=.5]{gauss-circle.eps}
    \caption{Lattice points in a circle of radius 6.}
    \label{fig:gauss-circle}
\end{figure}

Here is an example.

\begin{example} 
Suppose we want to count the number of lattice points in a circle of radius 6. (See Figure~\ref{fig:gauss-circle}.) This is $\GaussC(36)$. By Proposition~\ref{prop:gauss-R_n},  $\GaussC(36)=\GaussC(2\cdot18)=4\Rseq_{18}+4\cdot18+1$. We can calculate $\Rseq_{18}$ (or look it up in Figure~\ref{fig:first-20-terms}) to find $\Rseq_{18}=10$. Thus, the number of lattice points is $\GaussC(36)=4\cdot10+4\cdot18+1=113$.
\end{example}

Geometrically, we see that $\GaussC(n)$ is a non-decreasing function. For any $n\in\N$, 
\[
    0
    \le \GaussC(2n+2)-\GaussC(2n) 
    = 4\Rseq_{n+1}+4(n+1)+1-4\Rseq_{n}-4n-1 
    = 4\Rseq_{n+1}+4-4\Rseq_n.
\]
Thus, $\Rseq_{n+1}-\Rseq_n\ge-1$. This proves the following corollary.

\begin{cor}
    The sequence $(\Rseq_n)_{n\ge1}$ decreases by at most 1 in any step.
\end{cor}
A decrease of 1 from $\Rseq_n$ to $\Rseq_{n+1}$ occurs precisely when $2n+2$ and $2n+1$ each cannot be written as a sum of two integer squares. This occurs when the prime factorizations of $2n+2$ and $2n+1$ each contain some prime which is 3 modulo 4 raised to an odd power. From our data in Figure~\ref{fig:first-20-terms}, we see a decrease by 1 for $n=5$. Observe that $2n+2=12=2^2\cdot3^1$ and $2n+1=11^1$. Neither 11 nor 12 is a sum of two integer squares.

For comparison, there is no bound for the amount in which the sequences $(\Fseq_n)_{n\ge1}$ and $(\Cseq_n)_{n\ge1}$ can decrease in any step. Indeed, for $k\in\N$ and $n=2^k$, one finds $\Fseq_n-\Fseq_{n-1}=\Cseq_n-\Cseq_{n-1}=-(k-1)$.

We now want an asymptotic formula for $\Rseq_n$. To get there, we use an asymptotic result for $\GaussC(x)$ that is due to Gauss.
\begin{thm}\label{thm:gauss}
    For $x\ge1$, the number of lattice points in a closed disc of radius $\sqrt{x}$ is $\GaussC(x) = \pi x + \bigO\big(\sqrt{x}\big)$.
\end{thm}
This result appears widely in the literature. See, for instance, Rademacher \cite[Theorem 41]{Rademacher77} or Grosswald \cite[Chapter 2, Section 7]{Grosswald1985}.

We now compute an asymptotic formula for $\Rseq_n$.
\begin{prop}\label{prop:rounding_seq_asymp}
    Let $n\in\N$. Then $\Rseq_n = (\pi/2-1)n+\bigO\big(\sqrt{n}\big)$ and
    $\lim\limits_{n\to\infty}\frac{1}{n}\Rseq_n
        =\pi/2-1
        \approx 0.570796$.
\end{prop}

\begin{proof}
Combining Proposition~\ref{prop:gauss-R_n} and Theorem~\ref{thm:gauss}, we find
\begin{align*}
    \Rseq_n 
    &amp;= -n + (1/4)\cdot \big(\GaussC(2n) - 1\big) \\
    &amp;= -n + (1/4)\cdot \Big(2\pi n - 1 + \bigO\big(\sqrt{2n}\big)\Big) \\
    &amp;= -n + (\pi/2) n + \bigO\big(\sqrt{n}\big),
\end{align*}
which proves the first part. The limit behavior follows.
\end{proof}

\begin{remark}
    The error bound for $\GaussC(x)$ in Theorem~\ref{thm:gauss} has been improved since Gauss' original result. The \textit{Gauss circle problem} is to give the best error term. Just as is the case for the Dirichlet divisor problem, the best error bound currently known for $\GaussC(x)$ is $\bigO\big(x^{131/416}\big)$, also due to Huxley \cite{Huxley2002}. (Note that in that paper, Huxley considers the problem of lattice points in a circle of radius $x$ whereas we consider radius $\sqrt{x}$.) This gives us the following improved error bound for $\Rseq_n$:
    \[\Rseq_n = (\pi/2-1)n + \bigO\big(n^{131/416}\big).\]
\end{remark}

\begin{remark}\label{rmk:nint-half-integers}
    When we defined $\nint{x}$ in the introduction, we chose to always round up half-integers. Suppose we choose a different convention for rounding half-integers (e.g., always rounding down, or always rounding to the nearest even integer, or something else). Call the new rounding function $\nintp{x}$ and consider the sequence $(\Rseq_n')$ defined by
    \[
        \Rseq_n'
        =\#\{1\le k\le n : \nintp{n/k}\text{ is odd}\}.
    \]
    To compute $|\Rseq_n'-\Rseq_n|$, we need only consider those $k$ for which $n/k$ is a half-integer. But $n/k$ is a half-integer when $n/k=l/2$ for odd $l$, which means $k$ is a divisor of $2n$. By Lemma~\ref{lem:num_divisors_of_n}, the integer $2n$ has at most $2\sqrt{2n}$ divisors. Thus, there are at most $2\sqrt{2n}$ such $k$, and so
    \[
        |\Rseq_n'-\Rseq_n|
        \le 2\sqrt{2n},
    \]
    from which we conclude $\Rseq_n'=\Rseq_n+\bigO\big(\sqrt{n}\big)=n(\pi/2-1)+\bigO\big(\sqrt{n}\big)$. As a result, we have the same asymptotic behavior no matter the convention we use for rounding half-integers.
\end{remark}


\section{Counting by congruence class with shifted floors}\label{sec:generalized}
We can now generalize our results from the preceding sections in three ways.

First, recall that we can write $\nint{x}$ in terms of the floor function by $\nint{x}=\floor{x+1/2}$. We may therefore think of $\nint{x}$ as a \textit{$1/2$-shifted floor function} and the corresponding sequence
\[
    \NInt{\frac{n}{1}}, \NInt{\frac{n}{2}}, \dots, \NInt{\frac{n}{n}} 
    = 
    \FLoor{\frac{n}{1}+\frac{1}{2}}, \FLoor{\frac{n}{2}+\frac{1}{2}}, \dots, \FLoor{\frac{n}{n}+\frac{1}{2}}
\]
as a \textit{$1/2$-shifted floor sequence of length $n$}. We now consider an arbitrary shift $\alpha\in\R$.

Second, we now have sequences of length $n$ where the $k$th term, for $k\in\{1,2,\dots,n\}$, is $\floor{n/k + \alpha}$. We can offset the numerator $n$ by some real number $\nu$, resulting in a general term of the form $\floor{(n-\nu)/k+\alpha}$.

Third, when we defined $\Fseq_n$, $\Cseq_n$, and $\Rseq_n$ we focused on the number of odd terms in each sequence, which means counting the number of terms in each sequence which are congruent to 1 modulo 2. We now count the number of terms in each sequence that are congruent to $r$ modulo $m$ for integers $r$ and $m$ with $m\ge1$.

Let's set some notation. For $\alpha,\nu\in\R$, the \textit{$\alpha$-shifted, $\nu$-offset, floor sequence of length $n$} is 
\begin{equation}\label{seq:alpha-shift}
    \FLoor{\frac{n-\nu}{1}+\alpha}, \FLoor{\frac{n-\nu}{2}+\alpha}, \dots, \FLoor{\frac{n-\nu}{n}+\alpha}.
\end{equation}
For $r\in\Z$ and $m\in\N$, let $\Num_{n,\alpha,\nu,r,m}$ equal the number of integers in Seq.~\eqref{seq:alpha-shift} that are congruent to $r$ modulo $m$. In other words, let
\[
    \Num_{n,\alpha,\nu,r,m}
    =\#\Bigg\{1\le k\le n : \FLoor{\frac{n-\nu}{k}+\alpha}\equiv r\pmod*{m} \Bigg\}.
\]
Connecting to our earlier work, we see $\Fseq_n=\Num_{n,0,0,1,2}$ and $\Rseq_n=\Num_{n,1/2,0,1,2}$ for all $n\in\N$.

Since every integer is in exactly one congruence class modulo $m$, we immediately have 
\begin{equation}\label{eqn:sum-is-n}
    \sum\limits_{r=1}^m \Num_{n,\alpha,\nu,r,m}
    =n
\end{equation}
for all $n$, $\alpha$, $\nu$, and $m$. If we let $m=1$, we find $\Num_{n,\alpha,\nu,r,1}=n$ for all $n$, $\alpha$, $\nu$, and $r$. In what follows, we assume $m\ge2$. Furthermore, noting that $\Num_{n,\alpha,\nu,r,m} = \Num_{n,\alpha-1,\nu,r-1,m}$, we may suppose $\alpha\in[0,1)$. Next, since the difference $\Num_{n,\alpha,\nu,r,m}-\Num_{n-1,\alpha,\nu-1,r,m}$ is 1 or 0 depending on whether $\floor{(n-\nu)/n+\alpha}$ is congruent to $r$ modulo $m$ or not, we may suppose $\nu\in[0,1)$. Finally, it turns out to be useful to take $r\in[1,m]$, the least positive integer in a given congruence class modulo $m$.

\subsection{A sum of differences of floors}
Our first task is to write $\Num_{n,\alpha,\nu,r,m}$ as a sum of differences of floors. We generalize the approaches taken in writing $\Fseq_n$ (Proposition~\ref{prop:floor_seq}) and $\Rseq_n$ (Proposition~\ref{prop:rounding_seq}) as summations involving differences of floors.

The following lemma generalizes Lemma~\ref{lem:consec_flr} and Lemma~\ref{lem:round_count}.

\begin{lem}\label{lem:consec-general}
    For $\alpha,\nu\in[0,1)$, $k\in\N$, and $n\in\N$ with $n\alpha\ge\nu$, let $g(k)$ equal the number of integers in an $\alpha$-shifted, $\nu$-offset, floor sequence of length $n$ (Seq.~\eqref{seq:alpha-shift}) that are greater than or equal to $k$. Then
    \[
        g(k) = \begin{cases}
            n, &amp; \text{if $k=1$;}\\
            \floor{(n-\nu)/(k-\alpha)}, &amp; \text{if $k\ge2$}.
        \end{cases}
    \]
\end{lem}
\begin{proof}
    To start, we have $\nu&lt;1\le n$ for all $n$ Thus $n-\nu&gt;0$, which implies $(n-\nu)/1+\alpha, (n-\nu)/2+\alpha, \dots, (n-\nu)/n+\alpha$ is a decreasing sequence. Looking at the final term, since $\alpha\ge\nu/n$, we have 
    \[
        \frac{n-\nu}{n}+\alpha
        \ge \frac{n-\nu}{n}+\frac{\nu}{n}
        =1.
    \]
    Thus, every term in this sequence is at least 1, and hence their floors are at least 1. This means $g(1)=n$.
    
    Now, suppose $k\ge2$ and let $t=(n-\nu)/(k-\alpha)$. Observe that $0&lt;t&lt;n-\nu\le n$. We wish to show that the first $\floor{t}$ terms of Seq.~\eqref{seq:alpha-shift} are at least $k$ and that the remaining terms are less than $k$. Since Seq.~\eqref{seq:alpha-shift} is a non-increasing sequence, it suffices to show that
    \begin{equation}\label{eq:ineq-chain}
        \FLoor{\frac{n-\nu}{t}+\alpha}\ge k 
        &gt; 
        \FLoor{\frac{n-\nu}{t+1}+\alpha}.
    \end{equation}
    
    For the first inequality in Eq.~\eqref{eq:ineq-chain}, observe that
    \[
        \frac{n-\nu}{t}+\alpha
        = 
        \frac{n-\nu}{(n-\nu)/(k-\alpha)}+\alpha
        = k.
    \]
    Since $k$ is an integer, we have $\floor{(n-\nu)/t+\alpha}=\floor{k}=k\ge k$, as desired.
    
    For the second inequality in Eq.~\eqref{eq:ineq-chain}, we have
    \[
        \FLoor{\frac{n-\nu}{t+1}+\alpha} 
        \le 
        \frac{n-\nu}{t+1}+\alpha 
        &lt; 
        \frac{n-\nu}{t}+\alpha
        =
        k.
    \]
    This completes the proof.
\end{proof}
Note that in the above proof, we considered the cases $k=1$ and $k\ge2$ separately. Our argument for $k\ge2$ doesn't work for $k=1$ because, for $n\alpha&gt;\nu$, our value of $t$ would be $t=(n-\nu)/(1-\alpha)&gt;n$, and we cannot have more than $n$ terms in a sequence of $n$ terms.  This explains why we had to get rid of ``extra'' terms in the summation formula for $\Rseq_n$ (Proposition~\ref{prop:rounding_seq}), which involves $k=1$, $\alpha=1/2$, and $\nu=0$, whereas we had no such adjustment in the summation formula for $\Fseq_n$ (Proposition~\ref{prop:floor_seq}), which has $\alpha=\nu=0$.

In what follows, we count the number of terms in Seq.~\eqref{seq:alpha-shift} that are congruent to $r$ modulo $m$. Since we have slightly different results for $k=1$ and for $k\ge2$ in Lemma~\ref{lem:consec-general}, we obtain slightly different results for congruence classes with $r=1$ and with $2\le r\le m$ in the proposition (and subsequent results) below.

\begin{prop}\label{prop:generalized-sum-of-floors}
    Suppose $m\ge2$ and $\alpha,\nu\in[0,1)$. Then for all $n\in\N$ with $n\alpha\ge\nu$,
    \[
        \Num_{n,\alpha,\nu,1,m}
        = n-\FLoor{\frac{n-\nu}{1-\alpha}}+\sum\limits_{i\ge0} \Bigg(\FLoor{\frac{n-\nu}{1+im-\alpha}} - \FLoor{\frac{n-\nu}{2+im-\alpha}}\Bigg)
    \]
    and, for $2\le r\le m$, 
    \[
        \Num_{n,\alpha,\nu,r,m} 
        = \sum\limits_{i\ge0} \Bigg(\FLoor{\frac{n-\nu}{r+im-\alpha}} - \FLoor{\frac{n-\nu}{r+1+im-\alpha}}\Bigg).
    \]
\end{prop}
\begin{proof}
    By Lemma~\ref{lem:consec-general}, we have a formula for $g(d)$, the number of integers in Seq.~\eqref{seq:alpha-shift} that are greater than or equal to a given value $d$. Now, let $G(d)$ equal the number of integers in Seq.~\eqref{seq:alpha-shift} that are equal to a given value $d$. Then $G(d) = g(d)-g(d+1)$.
    
    We first compute $G(1)$ by $G(1) = g(1)-g(2) = n - \floor{(n-\nu)/2-\alpha}$. Then, for $d\ge2$, 
    \[
        G(d) 
        = g(d)-g(d+1) 
        = \floor{(n-\nu)/(d-\alpha)}-\floor{(n-\nu)/(d+1-\alpha)}.
    \]
    
    To compute $\Num_{n,\alpha,\nu,r,m}$, we need to count the number of integers in Seq.~\eqref{seq:alpha-shift} that are congruent to $r$ modulo $m$. Since $1\le r\le m$, we have \[\Num_{n,\alpha,\nu,r,m} = G(r) + G(r+m) + G(r+2m) + \cdots.\]
    
    For $2\le r\le m$, we have
    \[
        \Num_{n,\alpha,\nu,r,m} 
        = \sum\limits_{i\ge0}G(r+im) 
        = \sum\limits_{i\ge0}\Bigg(\FLoor{\frac{n-\nu}{r+im-\alpha}} - \FLoor{\frac{n-\nu}{r+1+im-\alpha}}\Bigg).
    \]
    
    For $r=1$, we have
    \[
        \Num_{n,\alpha,\nu,1,m} 
        = \sum\limits_{i\ge0}G(1+im) 
        = n - \FLoor{\frac{n-\nu}{2-\alpha}} + \sum\limits_{i\ge1}\Bigg(\FLoor{\frac{n-\nu}{1+im-\alpha}} - \FLoor{\frac{n-\nu}{2+im-\alpha}}\Bigg).
    \]
    If we include the $i=0$ term in the summation, to make it more closely resemble the formula for $r\ne 1$, we get the stated result.
\end{proof}



\subsection{An asymptotic formula via summation}
Our next task is to evaluate the sum 
\begin{equation}\label{eqn:next-to-evaluate}
    \sum\limits_{i\ge0}\Bigg(\FLoor{\frac{n-\nu}{r+im-\alpha}}-\FLoor{\frac{n-\nu}{r+1+im-\alpha}}\Bigg)
\end{equation}
that appears in Proposition~\ref{prop:generalized-sum-of-floors}. 

We start by simplifying $\frac{1}{n-\nu}$ times this sum. For $x\in\R$, let $\{x\}$ denote the fractional part of $x$, that is, $\{x\}=x-\floor{x}$. Then
\[
    \frac{1}{n-\nu}\sum\limits_{i\ge0}\Bigg(\FLoor{\frac{n-\nu}{r+im-\alpha}}-\FLoor{\frac{n-\nu}{r+1+im-\alpha}}\Bigg)
    =A_{\alpha,r,m}-\frac{1}{n-\nu}B_{n,\alpha,\nu,r,m}
\]
for the following quantities:
\[
    A_{\alpha,r,m}=\sum\limits_{i\ge0}\bigg(\frac{1}{r+im-\alpha}-\frac{1}{r+1+im-\alpha}\bigg),
\]
and
\[
    B_{n,\alpha,\nu,r,m}=\sum\limits_{i\ge0}\Bigg(\fpf{n-\nu}{r+im-\alpha}-\fpf{n-\nu}{r+1+im-\alpha}\Bigg).
\]

In general, the series $A_{\alpha,r,m}$ is an alternating series in which the absolute values of the terms decrease to zero. By the alternating series test, this series converges.

The series $B_{n,\alpha,\nu,r,m}$ is also an alternating series. If its terms, in absolute value, were decreasing, then we would have $B_{n,\alpha,\nu,r,m}=\bigO(1)$ and thus $(1/n) B_{n,\alpha,\nu,r,m}=\bigO(1/n)$. Unfortunately, this isn't the case. 

If we can find an asymptotic formula for $B_{n,\alpha,\nu,r,m}$, then we get an asymptotic formula for $\Num_{n,\alpha,\nu,r,m}$. To start, we revisit our results for $\Fseq_n$ and $\Rseq_n$ from earlier in this paper.

\begin{example}\label{ex:floor}
    The floor sequence $(\Fseq_n)_{n\ge1}$. 
    For $\alpha=\nu=0$, $r=1$, and $m=2$, we have $\Num_{n,0,0,1,2}=\Fseq_n$ for all $n\in\N$. Then 
\[
    A_{0,1,2}
    =\frac{1}{1}-\frac{1}{2}+\frac{1}{3}-\frac{1}{4}+\cdots
    =\sum\limits_{k=1}^\infty (-1)^{k+1}\frac{1}{k}
\]
and
\[
    B_{n,0,0,1,2} 
    =\fpf{n}{1}-\fpf{n}{2}+\fpf{n}{3}-\fpf{n}{4}+\cdots
    =\sum\limits_{k=1}^\infty (-1)^{k+1}\fpf{n}{k}.
\]
We see that $A_{0,1,2}=\log2$. (This is the Maclaurin series for $\ln(1+x)$, which converges for $-1&lt;x\le 1$, evaluated at $x=1$.)  Proposition~\ref{prop:floor_seq_asymp} implies that $\Num_{n,0,0,1,2}=\Fseq_n=n\log2+\bigO\big(\sqrt{n}\big)$. With the asymptotic formula for $\Fseq_n$ from Proposition~\ref{prop:generalized-sum-of-floors}, we find $B_{n,0,0,1,2}=\bigO\big(\sqrt{n}\big)$.
\end{example} 

\begin{example}\label{ex:rounding}
    The rounding sequence $(\Rseq_n)_{n\ge1}$. For $\alpha=1/2$, $\nu=0$, $r=1$, and $m=2$, we have $\Num_{n,1/2,0,1,2}=\Rseq_n$ for all $n\in\N$. Then
\[
    A_{1/2,1,2}
    =\frac{2}{1}-\frac{2}{3}+\frac{2}{5}-\frac{2}{7}+\cdots
    =\sum\limits_{k=0}^\infty(-1)^{k}\frac{2}{2k+1}
\]
and
\[
    B_{n,1/2,0,1,2} 
    =\fpf{2n}{1}-\fpf{2n}{3}+\fpf{2n}{5}-\fpf{2n}{7}+\cdots
    =\sum\limits_{k=0}^\infty(-1)^{k}\fpf{2n}{2k+1}.
\]
We see that $A_{1/2,1,2}=\pi/2$. (This is the Maclaurin series for $\arctan(x)$, which converges for $-1\le x\le 1$, evaluated at $x=1$.) Proposition~\ref{prop:rounding_seq_asymp} implies that $\Num_{n,1/2,0,1,2}=\Rseq_n=(\pi/2-1)n+\bigO\big(\sqrt{n}\big)$. With the asymptotic formula for $\Rseq_n$ from Proposition~\ref{prop:generalized-sum-of-floors}, we find $B_{n,1/2,0,1,2}=\bigO\big(\sqrt{n}\big)$.
\end{example} 

\begin{remark}\label{rmk:digamma}
    While we will not use any specific properties here, we note that the quantity $A_{\alpha,r,m}$ can be written in terms of the \textit{digamma} function $\psi(z)=\Gamma'(z)/\Gamma(z)$, the logarithmic derivative of the the gamma function, in the following way:
    \[A_{\alpha,r,m}=\frac{1}{m}\Bigg(\psi\bigg(\frac{r+1-\alpha}{m}\bigg)-\psi\bigg(\frac{r-\alpha}{m}\bigg)\Bigg).\]
\end{remark}

The examples above suggest that $B_{n,\alpha,\nu,r,m}=\bigO\big(\sqrt{n}\big)$ in general. This is in fact the case, as shown in Proposition~\ref{prop:sum-of-floors-to-sum-of-fractions} below.  For the proof, we use Dirichlet's hyperbola method. Our method is adapted from the approach given in an answer on Mathematics Stack Exchange \cite{MSE-floor-summation} which proved that, for an increasing sequence of positive integers $b_1,b_2,b_3,\dots$,  
\[
    \sum\limits_{k\le n}\FLoor{\frac{n}{b_k}}(-1)^k 
    = n\sum\limits_{k\le n}\frac{1}{b_k}(-1)^k + \bigO\big(\sqrt{n}\big).
\]
The terms in the floors of our series Eq.~\eqref{eqn:next-to-evaluate} are not necessarily integers, so we need to prove a slightly more general result. With this in mind, we introduce a generalized notion of ``divides.''

\begin{defn}[Real-ly divides]
    Let $a\in\R$ and $b\in\Z$. We say $a$ \textit{real-ly divides} $b$ if there is some $d\in\Z$ for which $\ceil{da}=b$. We denote this by $a\reallydivs b$, and we say $a$ is a \textit{real divisor} of $b$.
\end{defn}

To see that this definition generalizes the usual definition of ``divides,'' let's suppose that we have $a,b\in\Z$ with $a\mid b$. Then there is some $d\in\Z$ for which $da=b$. Hence, $\ceil{da}=da=b$, and so $a\reallydivs b$.

\begin{remark}
    We only apply this notion of \textit{real-ly divides} to working with positive numbers. If one wants to use this with negative numbers as well, it may be beneficial to modify the definition so that it has some symmetry with positive and negative numbers. One could say a real number $a$ real-ly divides an integer $b$ if there is some integer $d$ for which one of the following holds: either $b\ge0$ and $\ceil{da}=b$; or $b&lt;0$ and $\floor{da}=b$. With this, one would additionally have $a\reallydivs b$ if and only if $(-a)\reallydivs b$.
\end{remark}

The key property that we need is the following lemma.

\begin{lem}\label{lem:really-divides-summation}
    Let $n\in\N$, $\nu\in[0,1)$, and $a\in\R$ with $a\ge1$. Then 
    \[
        \FLoor{\frac{n-\nu}{a}} = \sum\limits_{\substack{1\le d\le n-\nu \\ a\reallydivs d}} 1.
    \]
\end{lem}
\begin{proof}
    To start, we have $n-\nu&gt;0$ and 
    \[
        \floor{(n-\nu)/a} 
        = \#\{ka  : k\in\Z,\, k\ge 1,\, ka\le n-\nu\}.
    \]
    Since $a\ge1$, we have $\ceil{k_1a}\ne\ceil{k_2a}$ for all integers $k_1\ne k_2$. Thus,
    \[
        \floor{(n-\nu)/a} 
        = \#\{\ceil{ka}  : k\in\Z,\, k\ge 1,\, ka\le n-\nu\}.
    \]
    But this is just the cardinality of the set of numbers that $a$ real-ly divides. We obtain
    \[
        \floor{(n-\nu)/a} 
        = \#\{d\in\Z  : 1\le d\le n-\nu,\, a\reallydivs d\} = \sum\limits_{\substack{1\le d\le n-\nu \\ a\reallydivs d}} 1,
    \]
    as desired.
\end{proof}

We can now apply Dirichlet's hyperbola method to show $B_{n,\alpha,\nu,r,m}=\bigO\big(\sqrt{n}\big)$.

\begin{prop}\label{prop:sum-of-floors-to-sum-of-fractions}
    For any increasing sequence $b_0,b_1,b_2,\dots$ of positive real numbers with the property that $b_k\ge1$ and $b_k\ge k$ for all $k$, we have
    \[
        \sum\limits_{k\le n-\nu}\FLoor{\frac{n-\nu}{b_k}}(-1)^k = n\sum\limits_{k\le n-\nu}\dfrac{(-1)^k}{b_k}+\bigO\big(\sqrt{n}\big).
    \]
\end{prop}
\begin{proof}
    Let 
        \[
            f(n)=\sum\limits_{k\le n-\nu} \FLoor{\frac{n-\nu}{b_k}}(-1)^k.
        \]
    To start, by Lemma~\ref{lem:really-divides-summation}, we have
    \[
        f(n) 
        = \sum\limits_{k\le n-\nu}(-1)^k\sum\limits_{\substack{d\le n-\nu \\ b_k\reallydivs d}} 1.
    \]
    Changing the order of summation,
    \[
        f(n)
        = \sum\limits_{d\le n-\nu}\sum\limits_{\substack{b_k\reallydivs d \\ k\le n-\nu}} (-1)^k.
    \]
    We are summing over $d\le n-\nu$ and real divisors $b_k$ of $d$. Thus, we have $b_k\le n-\nu$. As we have assumed that $b_k\ge k$, this implies $k\le n-\nu$. Thus, we need not explicitly state that $k\le n-\nu$.  We have
    \[
        f(n)
        = \sum\limits_{d\le n-\nu}\sum\limits_{b_k\reallydivs d} (-1)^k.
    \]
    If $b_k\reallydivs d$, then $d-1&lt;b_kd'\le d$. Thus, instead of summing over $d\le n-\nu$, we may sum over $d'$ and $k$ such that $b_kd'\le n-\nu$:
    \[
        f(n) 
        = \sum\limits_{b_kd'\le n-\nu}(-1)^k.
    \]

    We now apply Dirichlet's hyperbola method. Consider the region $R$ in the first quadrant of the $xy$-plane that is bounded by the hyperbola $xy=n-\nu$, the line $x=1$, and the line $y=1$. Let $A&gt;0$. We split the region $R$ into 3 subregions: $R_1$, the portion of $R$ which lies above the line $y=(n-\nu)/A$; $R_2$, the portion of $R$ which lies to the right of the line $x=A$; and $R_3$, which is the rectangle $[1,A]\times[1,(n-\nu)/A]$. (See Figure~\ref{fig:hyperbola}.)
    
    \begin{figure}[H]
        \centering
        \hspace{1in} 
        \includegraphics[scale=.7]{hyperbola.eps}
        \caption{The regions $R_1$, $R_2$, $R_3$.}
        \label{fig:hyperbola}
    \end{figure}
    
    It follows that for each combination of $b_k$ and $d'$ such that $b_kd'\le n-\nu$, there is a point $(x,y)=(d',b_k)$ in $R$. Hence, this point is in exactly one of $R_1$, $R_2$, $R_3$.
    
    We can sum over points $(d',b_k)$ in $R_1\cup R_3$ and $R_2\cup R_3$, and then subtract a summation over $R_3$ because we have double counted. We have
    \begin{equation}\label{eqn:dirichlet-eq-5}
        f(n) 
        = 
        \sum\limits_{d'\le A}\sum\limits_{b_k\le (n-\nu)/d'}(-1)^k 
        + \sum\limits_{b_k\le (n-\nu)/A}\sum\limits_{d'\le (n-\nu)/b_k}(-1)^k 
        - \sum\limits_{d'\le A}\sum\limits_{b_k\le (n-\nu)/A} (-1)^k.
    \end{equation}
    Since $b_0,b_1,b_2,\dots$ is an increasing sequence, the summation $\sum\limits_{b_k\le x}(-1)^k$ is equal to either 0 or 1, which is $\bigO(1)$. The first and third double sums in Eq.~\eqref{eqn:dirichlet-eq-5} are therefore $\bigO(A)$. Hence,
    \[
        f(n) 
        = \sum\limits_{b_k\le (n-\nu)/A}\sum\limits_{d'\le (n-\nu)/b_k}(-1)^k + \bigO(A)
        =\sum\limits_{b_k\le (n-\nu)/A}(-1)^k\FLoor{\frac{n-\nu}{b_k}}+\bigO(A).
    \]
    Then, since $\floor{(n-\nu)/b_k}=(n-\nu)/b_k + \bigO(1)$,
    \[
        f(n) =(n-\nu) \sum\limits_{b_k\le (n-\nu)/A} \frac{(-1)^k}{b_k} + \bigO\bigg(A+\frac{n-\nu}{A}\bigg).
    \]
    Taking $A=\sqrt{n-\nu}$, we have
    \[
        f(n) 
        = (n-\nu)\sum\limits_{b_k\le \sqrt{n-\nu}}\frac{(-1)^k}{b_k}+\bigO\big(\sqrt{n-\nu}\big)
    \]
    All that remains to do is modify the summation so that we sum over $k\le n-\nu$.  Let $K_n=\min\{k : b_k&gt;\sqrt{n-\nu}\}$. (Such a quantity exists because $b_k\ge k$ for all $k\in\Z$.) Then
    \[
        \Bigg|\sum\limits_{K_n\le k\le n}\dfrac{(-1)^k}{b_k}\Bigg|
        &lt;\Bigg|\frac{(-1)^{K_n}}{b_{K_n}}\Bigg|
        =\dfrac{1}{b_{K_n}}&lt;\dfrac{1}{\sqrt{n-\nu}}
        =\bigO\bigg(\dfrac{1}{\sqrt{n-\nu}}\bigg),
    \]
    where the first inequality holds because we have a finite alternating series.
    Thus, 
    \begin{align*}
        \sum\limits_{b_k\le\sqrt{n-\nu}}\dfrac{(-1)^k}{b_k}
        &amp;= \sum\limits_{k&lt; K_n}\dfrac{(-1)^k}{b_k} \\
        &amp;= \sum\limits_{k\le n-\nu}\dfrac{(-1)^k}{b_k} - \sum\limits_{K_n\le k\le n-\nu}\dfrac{(-1)^k}{b_k} \\
        &amp;= \sum\limits_{k\le n-\nu}\dfrac{(-1)^k}{b_k}+\bigO\big(1/\sqrt{n-\nu}\big).
    \end{align*}
    Therefore,
    \begin{align*}
        f(n)
        &amp;= (n-\nu)\sum\limits_{b_k\le \sqrt{n-\nu}}\frac{(-1)^k}{b_k}+\bigO\big(\sqrt{n-\nu}\big) \\
        &amp;= (n-\nu)\sum\limits_{k\le n-\nu}\dfrac{(-1)^k}{b_k}+\bigO\big(\sqrt{n-\nu}\big) \\
        &amp;= (n-\nu)\sum\limits_{k\le n-\nu}\dfrac{(-1)^k}{b_k}+\bigO\big(\sqrt{n}\big).
    \end{align*}
    Since $\nu$ times the convergent alternating sum is $\bigO(1)$, we get the stated result.
\end{proof}
\begin{remark}
    As mentioned in the introduction (Section~\ref{sec:question}), the best error bounds known for $\Fseq_n$ and $\Rseq_n$ are better than $\bigO\big(\sqrt{n}\big)$. It would be interesting to see if the result of Proposition~\ref{prop:generalized-sum-of-floors} could be similarly improved.
\end{remark} 

Combining Proposition~\ref{prop:generalized-sum-of-floors} and Proposition~\ref{prop:sum-of-floors-to-sum-of-fractions}, we obtain an asymptotic formula for $\Num_{n,\alpha,\nu,r,m}$. We first give the result for $2\le r\le m$, followed by a slight modification to get the result for $r=1$. (In the proof of Proposition~\ref{prop:generalized-sum-of-floors}, we saw that counting with $r=1$ is slightly different than counting with $r\ne1$. Fortunately, via Eq.~\eqref{eqn:sum-is-n}, if we can count for $r=2,\dots,m$, then we get a count for $r=1$ for free.)

\begin{cor}\label{cor:generalized-sum-of-floors}
    For $2\le r\le m$, and $\alpha,\nu\in[0,1)$, and $n\in\N$ with $n\alpha\ge\nu$,
    \[
        \Num_{n,\alpha,\nu,r,m} 
        = n\sum\limits_{i\ge0}\bigg(\frac{1}{r+im-\alpha}-\frac{1}{r+1+im-\alpha}\bigg) + \bigO\big(\sqrt{n}\big).
    \]
\end{cor}
\begin{proof}
     For integers $r,m$ with $2\le r\le m$ and for $\alpha\in[0,1)$, define the sequence $b_0,b_1,b_2,\dots$ as follows. For $i\ge0$, let $b_{2i}=(r+im)-\alpha$ and $b_{2i+1}=(r+im)-\alpha+1$. Then, for $\nu\in[0,1)$, 
     \begin{equation}\label{eqn:summation-floor-difference}
        \sum\limits_{k\le n-\nu}\FLoor{\frac{n-\nu}{b_k}}(-1)^k
        =
        \sum\limits_{i\ge0}\Bigg(\FLoor{\frac{n-\nu}{r+im-\alpha}}-\FLoor{\frac{n-\nu}{r+1+im-\alpha}}\Bigg).
    \end{equation}
    (While one series is finite and the other is infinite, the terms in the infinite series are zero for all  $i&gt;(n-\nu-r+\alpha)/m$ and hence there are no convergence issues.)
    
    We wish to show the sequence $b_0,b_1,b_2,\dots$ satisfies the conditions of Proposition~\ref{prop:sum-of-floors-to-sum-of-fractions}. We will show $b_k\ge 1$, $b_k\ge k$, and $b_{k+1}&gt;b_k$ for all $k\ge0$.
    
    If $k$ is even, then $k=2i$ for some $i$ and we have $b_k=(r+km/2)-\alpha$. Since $m\ge2$, we have $b_k\ge k + r-\alpha \ge k$. If $k$ is odd, then $k=2i+1$ for some $i$ and we have $b_k=r+(k-1)m/2-\alpha+1$. Since $m\ge2$, we have $b_k\ge (k-1)+r-\alpha+1\ge k$. Thus, $b_k\ge k$ for all $k\ge0$. Additionally, since $b_0=r-\alpha\ge2-\alpha&gt;1$ and $b_k\ge k\ge1$ for all $k\ge1$, we have $b_k\ge1$ for all $k\ge0$. Finally, for $k$ even, $b_{k+1}-b_k=1$, and for $k$ odd, $b_{k+1}-b_k=m-1\ge1$. Hence, $b_{k+1}&gt;b_k$ for all $k\ge0$.
     
    Since the sequence $b_0,b_1,b_2,\dots$ satisfies the conditions of Proposition~\ref{prop:sum-of-floors-to-sum-of-fractions}, we conclude that 
    \[
        \sum\limits_{k\le n-\nu}\FLoor{\frac{n-\nu}{b_k}}(-1)^k 
        = n\sum\limits_{k\le n-\nu}\frac{(-1)^k}{b_k} + \bigO\big(\sqrt{n}\big).
    \]
    Next, since we have an alternating series and $b_k\ge k$ for all $k$, we have 
    \[
        \Bigg|\sum\limits_{k&gt;n-\nu}\frac{(-1)^k}{b_k} \Bigg|
        &lt;\bigg|\frac{(-1)^{n}}{b_{n}}\bigg|
        =\frac{1}{b_{n}}
        &lt;\frac{1}{n}
        =\bigO\Big(\frac{1}{n}\Big).
    \]
    Thus,
    \begin{align*} 
        \sum\limits_{k\le n-\nu}\FLoor{\frac{n-\nu}{b_k}}(-1)^k 
        &amp;= n\sum\limits_{k\ge0}\frac{(-1)^k}{b_k}-n\sum\limits_{k&gt;n-\nu}\frac{(-1)^k}{b_k}+\bigO\big(\sqrt{n}\big) \\
        &amp;= n\sum\limits_{k\ge0}\frac{(-1)^k}{b_k} -n\bigO\Big(\frac{1}{n}\Big)+\bigO\big(\sqrt{n}\big) \\
        &amp;= n\sum\limits_{k\ge0}\frac{(-1)^k}{b_k}+\bigO(1)+ \bigO\big(\sqrt{n}\big).
    \end{align*}
    Combined with Eq.~\eqref{eqn:summation-floor-difference}, we conclude
    \[
        \sum\limits_{i\ge0}\Bigg(\FLoor{\frac{n-\nu}{r+im-\alpha}}-\FLoor{\frac{n-\nu}{r+1+im-\alpha}}\Bigg) \]
    is equal to
    \[
        n\sum\limits_{i\ge0}\bigg(\frac{1}{r+im-\alpha}-\frac{1}{r+1+im-\alpha}\bigg)+\bigO\big(\sqrt{n}\big).
    \]
    Together with Proposition~\ref{prop:generalized-sum-of-floors}, this proves the result for $2\le r\le m$.
\end{proof}

We now use Eq.~\eqref{eqn:sum-is-n} and Corollary~\ref{cor:generalized-sum-of-floors} to compute $\Num_{n,\alpha,\nu,r,m}$ for $r=1$.

\begin{cor}\label{cor:generalized-sum-of-floors-r=1}
    For any $m\ge2$, $\alpha,\nu\in[0,1)$, and $n\in\N$ with $n\alpha\ge\nu$,
    \[
        \Num_{n,\alpha,\nu,1,m} 
        = \frac{-\alpha n}{1-\alpha}+n\sum\limits_{i\ge0}\bigg(\frac{1}{1+im-\alpha}-\frac{1}{2+im-\alpha}\bigg) + \bigO\big(\sqrt{n}\big).
    \]
\end{cor}
\begin{proof}
    By Eq.~\eqref{eqn:sum-is-n}, 
    \[
        \Num_{n,\alpha,\nu,1,m} 
        = n-\sum\limits_{r=2}^m \Num_{n,\alpha,\nu,r,m}.
    \]
    Then, by Corollary~\ref{cor:generalized-sum-of-floors}
    \begin{align*}
        \Num_{n,\alpha,\nu,1,m} 
        &amp; = n - \sum\limits_{r=2}^m \Bigg(n\sum\limits_{i\ge0}\bigg(\frac{1}{r+im-\alpha}-\frac{1}{r+1+im-\alpha}\bigg)+\bigO\big(\sqrt{n}\big)\Bigg) \\
        &amp; = n - \sum\limits_{r=2}^m n\sum\limits_{i\ge0}\bigg(\frac{1}{r+im-\alpha}-\frac{1}{r+1+im-\alpha}\bigg)+\bigO\big(\sqrt{n}\big) \\
        &amp; = n - n\sum\limits_{i\ge0}\sum\limits_{r=2}^m\bigg(\frac{1}{r+im-\alpha}-\frac{1}{r+1+im-\alpha}\bigg) +\bigO\big(\sqrt{n}\big),
    \end{align*}
    where we have changed the order of summation in the last step because we have a finite number of convergent alternating series. We have a telescoping series for each $i\ge0$ which we can manipulate by 
    \begin{align*}
        \Num_{n,\alpha,\nu,1,m} 
        &amp; = n - n\sum\limits_{i\ge0} \bigg(\frac{1}{2+im-\alpha}-\frac{1}{m+1+im-\alpha}\bigg)+\bigO\big(\sqrt{n}\big) \\
        &amp; = n -\frac{n}{1-\alpha}+\frac{n}{1-\alpha}- n\sum\limits_{i\ge0} \bigg(\frac{1}{2+im-\alpha}-\frac{1}{m+1+im-\alpha}\bigg)+\bigO\big(\sqrt{n}\big) \\
        &amp;= n - \frac{n}{1-\alpha} + n\sum\limits_{i\ge0} \bigg(\frac{1}{1+im-\alpha}-\frac{1}{2+im-\alpha}\bigg)+\bigO\big(\sqrt{n}\big).
    \end{align*}
    Note that we have merely inserted $-n/(1-\alpha)+n/(1-\alpha)$ into our expression, and that we have not changed the order of summation in doing so. Hence,
    \[
        \Num_{n,\alpha,\nu,1,m}
        = \frac{-\alpha n}{1-\alpha} + n\sum\limits_{i\ge0} \bigg(\frac{1}{1+im-\alpha}-\frac{1}{2+im-\alpha}\bigg)+\bigO\big(\sqrt{n}\big),
    \]
    as desired.
\end{proof}

\subsection{An asymptotic formula via integration}
From integral calculus, we know how to evaluate sums like $1-1/2+1/3-1/4+\cdots$ and $1-1/3+1/5-1/7+\cdots$ via integration of Maclaurin series as mentioned in Example~\ref{ex:floor} and Example~\ref{ex:rounding}. We take the same approach to evaluate the summation that appears in Corollary~\ref{cor:generalized-sum-of-floors} and Corollary~\ref{cor:generalized-sum-of-floors-r=1}.
The following proposition shows us how. As with previous work in this section, we first obtain a result for $2\le r\le m$ and then use Eq.~\eqref{eqn:sum-is-n} to obtain a result for $r=1$.

\begin{prop}\label{prop:alt-sum-integral-formula}
    For integers $r$ and $m$ with $2\le r\le m$, and for any $\alpha\in [0,1)$,
    \[
        \sum\limits_{i\ge0}\bigg(\frac{1}{r+im-\alpha}-\frac{1}{r+1+im-\alpha}\bigg)
        =\int\limits_0^1\dfrac{(1-x)x^{r-1-\alpha}}{1-x^m}\dx.
    \]
\end{prop}
\begin{proof}
    To start, for $\beta=r-1-\alpha$, a positive real number, and for any non-negative integer $k$, let
    \[
        f_k(x)
        =x^{\beta}\sum\limits_{i=0}^k\big(x^{im}-x^{im+1}\big).
    \]
    Observe that $f_k(0)=f_k(1)=0$. For all $x\in(0,1)$ and all $k\ge0$,
    \begin{align*}
        |f_k(x)| 
        &amp;=\Bigg|x^\beta (1-x)\sum\limits_{i=0}^k x^{im} \Bigg| \\
        &amp;= \Bigg| x^\beta (1-x) \frac{1-x^{(k+1)m}}{1-x^m} \Bigg| \\
        &amp;= \Bigg| \frac{x^\beta}{1+x+x^2+\cdots+x^{m-1}} \Bigg| \Big|\big(1-x^{(k+1)m}\big)\Big|,
    \end{align*}
    a product of absolute values of two functions. Each absolute value is at most 1 for all $x\in(0,1)$. (We're using the fact that $\beta&gt;0$ here.) It follows that $|f_k(x)|\le 1\cdot1=1$ for all $x\in(0,1)$. Earlier, we saw $f_k(0)=f_k(1)=0$, so we can extend this interval to $[0,1]$. Since 1 is integrable on $[0,1]$, by the Dominated Convergence Theorem we have
    \[
        \lim\limits_{k\to\infty}\int\limits_0^1 f_k(x)\,\dx 
        = \int\limits_0^1 \lim\limits_{k\to\infty} f_k(x)\,\dx.
    \]
    
    Starting with the integral in the statement of this proposition, and applying this limit and integration interchange, we find
    \begin{align*}
        \int\limits_0^1\dfrac{(1-x)x^{r-1-\alpha}}{1-x^m}\dx
        &amp;= \int\limits_0^1 \lim\limits_{k\to\infty} f_k(x)\dx 
        = \lim\limits_{k\to\infty}\int\limits_0^1 f_k(x)\dx\\
        &amp;= \lim\limits_{k\to\infty} \int\limits_0^1 x^{\beta}\sum\limits_{i=0}^k \big(x^{im}-x^{im+1}\big)\dx \\
        &amp;= \lim\limits_{k\to\infty}\sum\limits_{i=0}^k \Bigg(\frac{x^{\beta+1+im}}{\beta+1+im} - \frac{x^{\beta+2+im}}{\beta+2+im}\Bigg)\Bigg|_{x=0}^{x=1} \\
        &amp; = \lim\limits_{k\to\infty}\sum\limits_{i=0}^k\Bigg(\frac{1}{\beta+1+im}-\frac{1}{\beta+2+im}\Bigg) \\
        &amp; = \sum\limits_{i=0}^\infty\Bigg(\frac{1}{r+im-\alpha}-\frac{1}{r+1+im-\alpha}\Bigg),
    \end{align*}
    as desired.
\end{proof}

Combining Corollary~\ref{cor:generalized-sum-of-floors} and Proposition~\ref{prop:alt-sum-integral-formula}, we obtain the following asymptotic formula for $\Num_{n,\alpha,\nu,r,m}$ with $2\le r\le m$, which we may then  extend to $r=1$ via Eq.~\eqref{eqn:sum-is-n}. This is our main result.

\begin{thm}\label{thm:N_m-asymp}
    Suppose $m\ge1$, $\alpha,\nu\in[0,1)$, and $n\in\N$ with $n\alpha\ge\nu$. Then
    \[
        \Num_{n,\alpha,\nu,1,m} = \frac{-\alpha n}{1-\alpha}+n\int\limits_0^1\dfrac{(1-x)x^{-\alpha}}{1-x^m}\dx + \bigO\big(\sqrt{n}\big),
    \]
    and, for $2\le r\le m$,
    \[
        \Num_{n,\alpha,\nu,r,m} = n\int\limits_0^1\dfrac{(1-x)x^{r-1-\alpha}}{1-x^m}\dx + \bigO\big(\sqrt{n}\big).
    \]
\end{thm}
\begin{proof}
    For $2\le r\le m$, the result follows from Corollary~\ref{cor:generalized-sum-of-floors} and Proposition~\ref{prop:alt-sum-integral-formula}. We need to prove the result for $r=1$.
    
    By Eq.~\eqref{eqn:sum-is-n},
    \[\Num_{n,\alpha,\nu,1,m} 
        = n - \sum\limits_{r=2}^m\Num_{n,\alpha,\nu,r,m}.\]
    Thus,
    \begin{align*}
        \Num_{n,\alpha,\nu,1,m}
        = n - \sum\limits_{r=2}^m\Num_{n,\alpha,\nu,r,m} 
        &amp;= n - \sum\limits_{r=2}^m \Bigg(n\int\limits_0^1\dfrac{(1-x)x^{r-1-\alpha}}{1-x^m}\dx+\bigO\big(\sqrt{n}\big)\Bigg) \\
        &amp;= n - n\int\limits_0^1\dfrac{x^{-\alpha}(1-x)}{1-x^m}\sum\limits_{r=2}^m x^{r-1}\dx+\bigO\big(\sqrt{n}\big).
    \end{align*}
    The finite series inside the integral will cancel with the denominator nicely if we include one more term. We do so as follows:
    \begin{align*}
        \Num_{n,\alpha,\nu,1,m} - n\int\limits_0^1 \dfrac{(1-x)x^{-\alpha}}{1-x^m}\dx &amp;= n - n\int\limits_0^1\dfrac{x^{-\alpha}(1-x)}{1-x^m}\sum\limits_{r=1}^m x^{r-1}\dx+\bigO\big(\sqrt{n}\big) \\
        &amp;=n-n\int\limits_0^1 x^{-\alpha}\dx +\bigO\big(\sqrt{n}\big).
    \end{align*}
    Since $0\le\alpha&lt;1$, this improper integral converges to $1/(1-\alpha)$. Solving for $\Num_{n,\alpha,\nu,1,m}$, we find
    \[
        \Num_{n,\alpha,\nu,1,m} = n - \frac{n}{1-\alpha} + n\int\limits_0^1\dfrac{(1-x)x^{-\alpha}}{1-x^m}\dx + \bigO\big(\sqrt{n}\big),
    \]
    which simplifies to the stated result.
\end{proof}

Observe that $\Num_{n,\alpha,\nu,r,m}$ is asymptotically linear and our formula is independent of $\nu$. We record the corresponding slope below in the following corollary.

\begin{cor}\label{cor:N_m-slope}
    For $\alpha,\nu\in[0,1)$ and $1\le r\le m$,
\[
    \lim\limits_{n\to\infty}\frac{1}{n}\Num_{n,\alpha,\nu,r,m} = \begin{cases}
        \displaystyle\dfrac{-\alpha}{1-\alpha}+\int\limits_0^1\dfrac{(1-x)x^{-\alpha}}{1-x^m}\dx, &amp; \text{if $r=1$;}\\
        \displaystyle\int\limits_0^1\dfrac{(1-x)x^{r-1-\alpha}}{1-x^m}\dx, &amp; \text{if $2\le r\le m$.}
    \end{cases}
\]
\end{cor}

Via integration, we can compute specific values of $\lim\limits_{n\to\infty}\frac{1}{n}\Num_{n,\alpha,\nu,r,m}$ for $1\le r\le m\le 4$. For $\alpha=\nu=0$, exact and rounded values are in Figure~\ref{fig:shift-0-exact-values} and Figure~\ref{fig:shift-0-decimals}. For $\alpha=1/2$ and $\nu=0$, exact and rounded values are in Figure~\ref{fig:shift-1/2-exact-values} and Figure~\ref{fig:shift-1/2-decimals}.

\begin{figure}[htb]
    \centering
    \begin{tabular}{c||c|c|c|c|} 
    \backslashbox{$r$}{$m$} &amp; 1 &amp; 2 &amp; 3 &amp; 4 \\ \hline \hline 
    1 &amp; $1$ &amp; $\log 2$ &amp; $\frac{1}{9} \, \sqrt{3} \pi$ &amp; $\frac{1}{8} \, \pi + \frac{1}{4} \, \log 2$ \\ \hline 
    2 &amp;  &amp; $-\log 2 + 1$ &amp; $-\frac{1}{18} \, \sqrt{3} \pi + \frac{1}{2} \, \log 3$ &amp; $\frac{1}{8} \, \pi - \frac{1}{4} \, \log 2$ \\ \hline 
    3 &amp;  &amp;  &amp; $-\frac{1}{18} \, \sqrt{3} \pi - \frac{1}{2} \, \log 3 + 1$ &amp; $-\frac{1}{8} \, \pi + \frac{3}{4} \, \log 2$ \\ \hline 
    4 &amp;  &amp;  &amp;  &amp; $-\frac{1}{8} \, \pi - \frac{3}{4} \, \log 2 + 1$ \\ \hline 
    \end{tabular}
    \caption{Values of $\lim\limits_{n\to\infty}\frac{1}{n}\Num_{n,0,0,r,m}$ for $1\le m\le 4$.}
    \label{fig:shift-0-exact-values}
\end{figure}

\begin{figure}[htb]
    \centering
    \begin{tabular}{c||c|c|c|c|} 
    \backslashbox{$r$}{$m$} &amp; 1 &amp; 2 &amp; 3 &amp; 4 \\ \hline \hline 
    1 &amp; $1.000000$ &amp; $0.693147$ &amp; $0.604600$ &amp; $0.565986$ \\ \hline 
    2 &amp;  &amp; $0.306853$ &amp; $0.247006$ &amp; $0.219412$ \\ \hline 
    3 &amp;  &amp;  &amp; $0.148394$ &amp; $0.127161$ \\ \hline 
    4 &amp;  &amp;  &amp;  &amp; $0.087441$ \\ \hline 
    \end{tabular}
    \caption{$\lim\limits_{n\to\infty}\frac{1}{n}\Num_{n,0,0,r,m}$ for $1\le m\le 4$, rounded to 6 decimal places.}
    \label{fig:shift-0-decimals}
\end{figure}

\begin{figure}[htb]
    \centering
    \begin{tabular}{c||c|c|c|c|} 
    \backslashbox{$r$}{$m$} &amp; 1 &amp; 2 &amp; 3 &amp; 4 \\ \hline \hline 
    1 &amp; $1$ &amp; $\frac{1}{2} \, \pi - 1$ &amp; $\frac{1}{6} \, \sqrt{3} \pi + \frac{1}{2} \, \log 3 - 1$ &amp; $\frac{1}{4} \, \pi + \frac{1}{4} \, \sqrt{2} \log\big(3+2\sqrt{2}\big) - 1$ \\ \hline 
    2 &amp;  &amp; $-\frac{1}{2} \, \pi + 2$ &amp; $\frac{1}{6} \, \sqrt{3} {\big(\pi - \sqrt{3} \log 3\big)}$ &amp; $\frac{1}{4} \, \pi {\big(\sqrt{2} - 1\big)}$ \\ \hline 
    3 &amp;  &amp;  &amp; $-\frac{1}{3} \, \sqrt{3} \pi + 2$ &amp; $\frac{1}{4} \, \pi - \frac{1}{4} \, \sqrt{2} \log\big(3+2\sqrt{2}\big)$ \\ \hline 
    4 &amp;  &amp;  &amp;  &amp; $-\frac{1}{4} \, \pi {\big(\sqrt{2} + 1\big)} + 2$ \\ \hline 
    \end{tabular}
    \caption{Values of $\lim\limits_{n\to\infty}\frac{1}{n}\Num_{n,1/2,0,r,m}$ for $1\le m\le 4$.}
    \label{fig:shift-1/2-exact-values}
\end{figure}

\begin{figure}[htb]
    \centering
    \begin{tabular}{c||c|c|c|c|} 
    \backslashbox{$r$}{$m$} &amp; 1 &amp; 2 &amp; 3 &amp; 4 \\ \hline \hline 
    1 &amp; $1.000000$ &amp; $0.570796$ &amp; $0.456206$ &amp; $0.408623$ \\ \hline 
    2 &amp;  &amp; $0.429204$ &amp; $0.357594$ &amp; $0.325323$ \\ \hline 
    3 &amp;  &amp;  &amp; $0.186201$ &amp; $0.162173$ \\ \hline 
    4 &amp;  &amp;  &amp;  &amp; $0.103881$ \\ \hline 
    \end{tabular}
    \caption{$\lim\limits_{n\to\infty}\frac{1}{n}\Num_{n,1/2,0,r,m}$ for $1\le m\le 4$, rounded to 6 decimal places.}
    \label{fig:shift-1/2-decimals}
\end{figure}



\section{Applications to finding parity and counting lattice points}\label{sec:applications}
Now that we have a formula for $\Num_{n,\alpha,\nu,r,m}$, we focus on a few applications: computing a floor shift which results in an asymptotic 50/50 split of even and odd terms; and counting lattice points in a few families of ellipses.

\subsection{Shifting for parity}\label{subsec:parity}
We return to the case where $m=2$ and consider the problem of determining a shift $\alpha$ so that half of the terms are odd and half are even. It amounts to computing $\alpha$ for which 
\[ 
    \lim\limits_{n\to\infty}\frac{1}{n}\Num_{n,\alpha,\nu,1,2}
    =\lim\limits_{n\to\infty}\frac{1}{n}\Num_{n,\alpha,\nu,2,2}
    =1/2.
\]
By Corollary~\ref{cor:N_m-slope} (with the formula for $r=2$ to avoid the extra term out front), we need $\alpha$ such that
\[
    \int\limits_0^1\dfrac{(1-x)x^{1-\alpha}}{1-x^2}\dx 
    = \int\limits_0^1\dfrac{x^{1-\alpha}}{1+x}\dx 
    = 1/2.
\]
(Note that this is independent of $\nu$.) Since we're using $r=2$, for the remainder of this subsection, we count even integers instead of odd integers in an $\alpha$-shifted floor sequence.

\begin{figure}[htb]
    \centering
    \includegraphics[width=.6\textwidth]{f-alpha-plot.eps}
    \caption{Plot of $\displaystyle y=p_e(\alpha) = \int\limits_0^1\dfrac{x^{1-\alpha}}{1+x}\dx$ for $\alpha\in[0,1]$.
    }
    \label{fig:p_e(alpha) plot}
\end{figure}


Let 
\[
    p_e(\alpha)
    =\int\limits_0^1\dfrac{x^{1-\alpha}}{1+x}\dx.
\]
Then $p_e(\alpha)$ is the (asymptotic) proportion of terms in an $\alpha$-shifted floor sequence of length $n$ that are even. We immediately see that $p_e(\alpha)$ is continuous, increasing, and concave up for $\alpha\in[0,1]$.  Furthermore,  $p_e(0)=1-\log2 &lt; 1/2$ and $p_e(1)=\log2 &gt; 1/2$. Thus, there is a unique shift $\alpha_0\in(0,1)$ for which $p_e(\alpha_0)=1/2$. A plot of $p_e(\alpha)$ appears in Figure~\ref{fig:p_e(alpha) plot}. We see that the value of $\alpha$ for which $p_e(\alpha)=1/2$ is between $0.6$ and $0.7$.

Computing with Sage \cite{sage}, we can shrink the interval down. We compute
\[
    p_e(0.682379227335) &lt; 1/2 
    \text{ and } 
    p_e(0.682379227345) &gt; 1/2.
\]
Hence, we have $p_e(\alpha_0)=1/2$ for 
\[
    \alpha_0
    \approx 0.68237922734.
\]

We have generated some data with this approximate value. A plot of $y=\Num_{n,0.68237922734,0,2,2}$ appears in Figure~\ref{fig:alpha_0_sequence_plot} along with the graph of $y=n/2$. In Figure~\ref{fig:alpha_0_random_table} gives values of $\Num_{n,0.68237922734,0,2,2}$ for random $n$ with $10^5&lt;n&lt;10^6$.

\begin{figure}[H]
    \centering
    \includegraphics[width=.6\textwidth]{alpha_0_sequence.eps}
    \caption{Plot of $y=\Num_{n,\alpha,0,2,2}$ for $\alpha=0.68237933734$ and $1\le n\le 1000$ (black) along with the graph of $y=n/2$ (blue).}
    \label{fig:alpha_0_sequence_plot}
\end{figure}

\begin{figure}[H]
    \centering
    \begin{tabular}{|c|c|c|}\hline &amp; &amp; \\
    $n$ &amp; number of even terms 
    &amp; proportion of even terms 
    \\ &amp; &amp; \\
    \hline 
    $ 7015 $ &amp; $ 3503 $ &amp; $49.9359\%$ \\ 
    $ 179220 $ &amp; $ 89632 $ &amp; $50.0123\%$ \\ 
    $ 213788 $ &amp; $ 106901 $ &amp; $50.0033\%$ \\ 
    $ 267093 $ &amp; $ 133562 $ &amp; $50.0058\%$ \\ 
    $ 439675 $ &amp; $ 219839 $ &amp; $50.0003\%$ \\ 
    $ 491213 $ &amp; $ 245600 $ &amp; $49.9987\%$ \\ 
    $ 503521 $ &amp; $ 251741 $ &amp; $49.9961\%$ \\ 
    $ 689325 $ &amp; $ 344631 $ &amp; $49.9954\%$ \\ 
    $ 775294 $ &amp; $ 387629 $ &amp; $49.9977\%$ \\ 
    $ 978029 $ &amp; $ 489010 $ &amp; $49.9995\%$ \\  
    \hline
    \end{tabular}
    \caption{The number and proportion of even terms in an $\alpha$-shifted, $\nu$-offset, floor sequence of length $n$ for $\alpha=0.68237933634$ and various random $n$ with $10^5&lt;n&lt;10^6$.}
    \label{fig:alpha_0_random_table}
\end{figure}

\subsection{Lattice points in selected ellipses, number rings, and plane tilings}
Since $\Num_{n,1/2,0,1,2}=\Rseq_n$, Proposition~\ref{prop:gauss-R_n} says that the number of lattice points in a disc of radius $\sqrt{2n}$ centered at the origin is $4\Num_{n,1/2,0,1,2}+4n+1$. In this subsection, we present a formula for the number of lattice points in a disc of radius $\sqrt{n}$ in terms of $\Num_{n,\alpha,\nu,r,m}$. We then find similar formulas for the number of lattice points contained in the ellipses
\[
    x^2+xy+y^2=n \quad\text{and } x^2+2y^2=n.
\]


In Proposition~\ref{prop:generalized-sum-of-floors}, we wrote $\Num_{n,\alpha,\nu,1,m}$ with a summation involving a difference of floors. In what follows, it is useful to have the formula for $\Num_{n,\alpha,\nu,1,m}$ in the case where $\alpha$ is rational. If we suppose $\alpha=p/q$, then
\begin{equation} \label{eqn:num-rational-alpha}
    \Num_{n,p/q,\nu,1,m}=n - \FLoor{\frac{(n-\nu)q}{q-p}} + \sum\limits_{i\ge0}\Bigg(\FLoor{\frac{(n-\nu)q}{q+qim-p}}-\FLoor{\frac{(n-\nu)q}{2q+qim-p}} \Bigg)
\end{equation}
for all $n\in\N$ with $n\alpha\ge\nu$.

Also, for $n\in\N$, recall the function $\divs_{r,m}(n)$ which counts the number of positive divisors of $n$ that are congruent to $r$ modulo $m$.


\subsubsection{Lattice points in the region $x^2+y^2\le n$}
In Proposition~\ref{prop:gauss-R_n}, we found a formula for the number of lattice points $(x,y)\in\Z^2$ contained in the disc $x^2+y^2\le 2n$ in terms of $\Rseq_n$. This is a result for discs with radius equal to the square root of an even number. We can extend the result to square roots of odd numbers as well, eventually obtaining a formula for the number of lattice points contained in the disc $x^2+y^2\le n$. 

For $n\ge0$, again let $\GaussC(n)$ be the number of lattice points contained in the circular region $x^2+y^2\le n$. Then 
\[
    (\GaussC(n))_{n\ge0} = (1, 5, 9, 9, 13, 21, 21, 21, 25, 29, 37,\dots),
\]
which is sequence \seqnum{A057655} in OEIS. By the above proposition, we can compute $\GaussC(n)$ as follows with the help of $\Num_{\ceil{n/2},1/2,\{n/2\},1,2}$, where $\{n/2\}$ denotes the fractional part of $n/2$.

\begin{prop}\label{prop:circle-radius-n}
    For $n\in\N$, the number of lattice points in a disc of radius $\sqrt{n}$ centered at the origin is 
    \[
        \GaussC(n) = 
        4\Num_{\ceil{n/2},1/2,\{n/2\},1,2}+4\floor{n/2}+1.
    \]
    
\end{prop}
\begin{proof}
    Let $\GaussC(n)=\#\big\{(x,y)\in\Z^2 : x^2+y^2\le n\big\}$. We consider the cases of even $n$ and odd $n$ separately.
    
    If $n$ is even, then $n=2k$ for some $k\in\N$.  By Proposition~\ref{prop:gauss-R_n}
    \[
        \GaussC(n) 
        = \GaussC(2k) 
        = 4\Rseq_k+4k+1=4\Num_{k,1/2,0,1,2}+4k+1=4\Num_{n/2,1/2,0,1,2}+2n+1.
    \]
    Note that $\ceil{n/2}=k=n/2$, $\{n/2\}=\{k\}=0$, and $4\floor{n/2}=4\floor{k}=4k=2n$. This proves the formula for $\GaussC(n)$ with $n$ even.
    
    If $n$ is odd, then $n=2k-1$ for some $k\in\N$. By Jacobi's two-square theorem (Theorem~\ref{thm:jacobi}), 
    \[
        \GaussC(n) 
        = 1 + 4\sum\limits_{j=1}^n\big(\divs_{1,4}(j)-\divs_{3,4}(j)\big) 
        = 1 + 4\bigg(\FLoor{\frac{n}{1}}-\FLoor{\frac{n}{3}}+\FLoor{\frac{n}{5}}-\FLoor{\frac{n}{7}}+\cdots\bigg).
    \]
    In order to get this alternating floor sum, we use $\alpha=\nu=1/2$, $r=1$, and $m=2$ with Eq.~\eqref{eqn:num-rational-alpha}. We have
    \[
        \Num_{k,1/2,1/2,1,2}
        =1-k+\sum\limits_{i\ge0}\Bigg(\FLoor{\frac{2k-1}{4i+1}}-\FLoor{\frac{2k-1}{4i+3}}\Bigg) 
        = \frac{1-n}{2}+\sum\limits_{i\ge0}\Bigg(\FLoor{\frac{n}{4i+1}}-\FLoor{\frac{n}{4i+3}}\Bigg)
    \]
    for all $k\ge\nu/\alpha=1$. Then, 
    \[
        \GaussC(n) 
        = 1 + 4\bigg(\Num_{k,1/2,1/2,1,2}+\frac{n-1}{2}\bigg) 
        = 1 + 4\Num_{(n+1)/2,1/2,1/2,1,2}+2n-2.
    \]
    Note that $\ceil{n/2}=k=(n+1)/2$, $\{n/2\}=\{k+1/2\}=1/2$, and $4\floor{n/2}=4\floor{k-1/2}=4(k-1)=2n-2$. This proves the formula for $\GaussC(n)$ with $n$ odd.
\end{proof}

\begin{example}\label{ex:gaussian-ints}
To illustrate Proposition~\ref{prop:circle-radius-n}, we can compute the number of lattice points in a disc of radius $\sqrt{13}$. Note that $\ceil{13/2}=7$. The number of lattice points in a disc of radius $\sqrt{13}$ involves the quantity $4\Num_{7,1/2,1/2,1,2}$. To compute this, we examine the length-7 sequence 
\[
    \FLoor{\frac{7-1/2}{1}+\frac{1}{2}},\FLoor{\frac{7-1/2}{2}+\frac{1}{2}},\dots,\FLoor{\frac{7-1/2}{7}+\frac{1}{2}} 
    = 7,3,2,2,1,1,1,
\]
which contains 5 odd terms. Thus, $\Num_{7,1/2,1/2,1,2}=5$. By Proposition~\ref{prop:circle-radius-n}, the number of lattice points in a disc of radius $\sqrt{13}$ is therefore 
\[
    \GaussC(13)
    =4\Num_{7,1/2,1/2,1,2}+4\floor{13/2}+1
    = 4\cdot5+4\cdot6+1=45.
\]
A disc of radius $\sqrt{13}$ appears in Figure~\ref{fig:sqrt-13-disc}, and one confirms there are 45 lattice points.
\end{example}

\begin{figure}[H]
    \centering
    \includegraphics[scale=.6]{circle-sqrt-13.eps}
    \caption{The 45 lattice points in a disc of radius $\sqrt{13}$, which are also the 45 Gaussian integers with norm at most 13.}
    \label{fig:sqrt-13-disc}
\end{figure}

\begin{remark}
    We mentioned the ring of Gaussian integers, $\Z[i]$, earlier. For any $z=a+bi\in\Z[i]$, the norm of $z$ is $N(z)=N(a+bi)=a^2+b^2$. Thus, Proposition~\ref{prop:circle-radius-n} gives a formula for the number of Gaussian integers with norm at most $n$. Following from Example~\ref{ex:gaussian-ints}, we know there are 45 Gaussian integers with norm at most 13. We visualize these Gaussian integers in Figure~\ref{fig:sqrt-13-disc}.   
\end{remark}

\subsubsection{Lattice points in the region $x^2+xy+y^2\le n$}
Next, we consider the ellipse $x^2+xy+y^2=n$. In general, the quantity $ax^2+bxy+cy^2$, for constants $a,b,c$, is a \textit{binary quadratic form}. We take results about the number of representations of an integer $n$ by a binary quadratic form from Dickson's book \cite{Dickson1958}.

\begin{prop}[{\cite[Exercise XXII.2]{Dickson1958}}]\label{prop:dickson-x^2+xy+y^2}
    Let $n\in\N$. Then the number of representations of $n=x^2+xy+y^2$, for integers $x,y$, is $6\big(\divs_{1,3}(n)-\divs_{2,3}(n) \big)$.
\end{prop}

For $n\ge0$, let $\Ellip(n)$ be the number of lattice points contained in the elliptical region $x^2+xy+y^2\le n$. Then 
\[
    (\Ellip(n))_{n\ge0} = (1, 7, 7, 13, 19, 19, 19, 31, 31, 37, 37, 37, \dots),
\]
which is sequence \seqnum{A038589} in OEIS. By the above proposition, we can compute $\Ellip(n)$ by counting the number of terms in a floor sequence of length $n$ that are 1 modulo 3.

\begin{cor}\label{cor:lattice-points-eisenstein-ellipse}
    For $n\in\N$, the number of lattice points contained in the elliptical region $x^2+xy+y^2\le n$ is 
    \[
        \Ellip(n)
        = 6\Num_{n,0,0,1,3}+1.
    \]
\end{cor}
\begin{proof}
    Let $f(n)=\#\big\{(x,y)\in\Z^2 : x^2+xy+y^2=n\big\}$. Observe that $f(0)=1$. Thus,
    \begin{equation}\label{eqn:f-step-2}
        \Ellip(n) = \sum\limits_{k=0}^n f(k) = 1 + \sum\limits_{k=1}^n f(k).
    \end{equation}
    Next, by Proposition~\ref{prop:dickson-x^2+xy+y^2}, 
    \[
        \sum\limits_{k=1}^n f(k)
        = 6\bigg(\FLoor{\frac{n}{1}}-\FLoor{\frac{n}{2}}+\FLoor{\frac{n}{4}}-\FLoor{\frac{n}{5}}+\FLoor{\frac{n}{7}}-\cdots\bigg),
    \]
    which is a finite sum since the floors are eventually zero. Using $\alpha=\nu=0$, $r=1$, and $m=3$ with Eq.~\eqref{eqn:num-rational-alpha}, we get
    \[
        \Num_{n,0,0,1,3}
        =\bigg(\FLoor{\frac{n}{1}}-\FLoor{\frac{n}{2}}+\FLoor{\frac{n}{4}}-\FLoor{\frac{n}{5}}+\FLoor{\frac{n}{7}}-\cdots\bigg)
    \]
    for all $n\in\N$. We conclude that $\Ellip(n) = 1 + 6\Num_{n,0,0,1,3}$,
    as desired.
\end{proof}

\begin{example}\label{ex:ellipse-30}
    We compute the number of lattice points contained in the ellipse defined by the equation $x^2+xy+y^2=30$. To do so, we consider the sequence
    \[
        \FLoor{\frac{30}{1}},\FLoor{\frac{30}{2}},\dots,\FLoor{\frac{30}{30}} = 30, 15, 10, 7, 6, 5, 4, 3 (3), 2 (5), 1 (15),
    \]
    where the number in parentheses indicates the number of terms with that value. There are 18 terms in this sequence that are congruent to 1 modulo 3. Hence, 
    the ellipse defined by the equation $x^2+xy+y^3=30$ contains $6\Num_{30,0,0,1,3}+1=6\cdot18+1=109$ lattice points. See Figure~\ref{fig:ellipse-30}.
\end{example}

\begin{figure}[H]
    \centering
    \includegraphics[scale=.6]{x2pxypy2e30.eps}
    \includegraphics[scale=.6]{eisensten-30.eps}
    \caption{The 109 lattice points within the ellipse $x^2+xy+y^2=30$, and the 109 Eisenstein integers with norm at most 30.}
    \label{fig:ellipse-30}
\end{figure}


From Theorem~\ref{thm:N_m-asymp} and Figure~\ref{fig:shift-0-exact-values}, we see that $\Num_{n,0,0,1,3}=\frac{1}{9}\sqrt{3}\pi n+\bigO\big(\sqrt{n}\big)$. We immediately obtain the following corollary.

\begin{cor}\label{cor:lattice-points-x2+xy+y2}
    For $n\in\N$, the number of lattice points in the elliptical region $x^2+xy+y^2\le n$ is  $\frac{2}{3}\sqrt{3}\pi n + \bigO\big(\sqrt{n}\big)$.
\end{cor}

\begin{remark} 
    Consider the ring of Eisenstein integers, $\Z[\omega]$, where $\omega=\frac{-1+\sqrt{-3}}{2}$, a primitive 3rd root of unity. For $z=a-b\omega\in\Z[\omega]$, the norm of $z$ is $N(z)=N(a-b\omega)=a^2+ab+b^2$. Thus, Corollary~\ref{cor:lattice-points-eisenstein-ellipse} gives a formula for the number of Eisenstein integers with norm at most $n$. Following from Example~\ref{ex:ellipse-30}, we know there are 109 Eisenstein integers with norm at most 30. We visualize these Eisenstein integers in Figure~\ref{fig:ellipse-30}.
\end{remark} 

In general, the Eisenstein integers form a hexagonal (or triangular) lattice in the complex plane where neighboring Eisenstein integers are 1 unit apart. We can now count the number of such lattice points contained in a disc.

\begin{cor}\label{cor:hex-lattice-points}
    In a hexagonal lattice where neighboring lattice points are one unit apart, the number of lattice points in a disc of radius $\sqrt{n}$ is $1+6\Num_{n,0,0,1,3}$, where $\Num_{n,0,0,1,3}$ is the number of integers in the sequence 
\[
    \FLoor{\frac{n}{1}}, \FLoor{\frac{n}{2}}, \dots, \FLoor{\frac{n}{n}}
\]
that are 1 modulo 3.
\end{cor}

The sequence $(\Num_{n,0,0,1,3})_{n\ge0} = (0,1,1,2,3,3,3,5,5,\dots)$ is \seqnum{A014202} in OEIS.

\subsubsection{Lattice points in the region $x^2+2y^2\le n$}
We now consider the ellipse $x^2+2y^2=n$. The result below gives the number of representations of a natural number $n$ in terms of the binary quadratic form $x^2+2y^2$.

\begin{prop}[{\cite[Exercise XXII.1]{Dickson1958}}]
\label{prop:dickson-x^2+2y^2}
    Let $n\in\N$. Then the number of representations of $n=x^2+2y^2$, for integers $x,y$, is $2\big(\divs_{1,8}(n)+\divs_{3,8}(n)-\divs_{5,8}(n)-\divs_{7,8}(n) \big)$.
\end{prop}

\begin{cor}\label{cor:x^2+2y^2}
    Let $F(n)$ be the number of lattice points contained in the elliptical region $x^2+2y^2\le n$. Then $F(0)=1$, $F(1)=3$, $F(2)=5$, $F(5)=11$, and for all $n\in\N$ with $n\ne 1,2,5$, 
    \[
        F(n) 
        = 1+2\Num_{\ceil{n/4},3/4,\{-n/4\},1,2}+2\Num_{\ceil{n/4},1/4,\{-n/4\},1,2}+2n+2\floor{n/3}-4\ceil{n/4}.
    \]
\end{cor}
\begin{proof}
    Let $f(n) = \#\big\{(x,y)\in\Z^2 : x^2+2y^2=n\big\}$. Observe that $f(0)=1$. To start, we have
    \begin{equation}\label{eqn:f-step-1}
        F(n)
        = \sum\limits_{k=0}^n f(k) 
        = 1 + \sum\limits_{k=1}^n f(k).
    \end{equation}
    Next, by Proposition~\ref{prop:dickson-x^2+2y^2}, 
    \[
        \sum\limits_{k=1}^n f(k) 
        =  2\Bigg(\FLoor{\frac{n}{1}}+\FLoor{\frac{n}{3}}-\FLoor{\frac{n}{5}}-\FLoor{\frac{n}{7}}+\FLoor{\frac{n}{9}}+\cdots\Bigg),
    \]
    which is a finite sum since the floors are eventually zero. We need two alternating floor sums here: one for $\floor{n/1}-\floor{n/5}+\floor{n/9}-\cdots$; and one for $\floor{n/3}-\floor{n/7}+\floor{n/11}-\cdots$. Each requires $q=4$ and $m=2$. As was the case with computing the number of lattice points in a disc of radius $\sqrt{n}$ (Proposition~\ref{prop:circle-radius-n}), we have $\nu\ne0$ here as well.
    
    For $n\in\N$, let $a=\ceil{n/4}$ and $b=4a-n$. Then $0\le b&lt;4$. Using $\alpha=p/q=3/4$, $\nu=b/4$, $r=1$, and $m=2$ with Eq.~\eqref{eqn:num-rational-alpha}, we get
    \[
        \Num_{a,3/4,b/4,1,2} = a - \FLoor{\frac{n}{1}} + \sum\limits_{i\ge0}\Bigg(\FLoor{\frac{n}{1+4i}}-\FLoor{\frac{n}{5+4i}}\Bigg)
    \]
    for all $a\ge\nu/\alpha=b/3$. 
    Using $\alpha=p/q=1/4$, $\nu=b/4$, $r=1$, and $m=2$ with Eq.~\eqref{eqn:num-rational-alpha}, we get
    \[
        \Num_{a,1/4,b/4,1,2} = a - \FLoor{\frac{n}{3}} + \sum\limits_{i\ge0}\Bigg(\FLoor{\frac{n}{3+4i}}-\FLoor{\frac{n}{7+4i}}\Bigg)
    \]
    for all $a\ge\nu/\alpha=b$.
    
    Both equations hold for $a\ge b$. Since $a\ge1$ and $0\le b&lt;4$, this inequality is satisfied for all $a,b$ except for $(a,b)=(1,2), (1,3), (2,3)$, which correspond, respectively, to $n=2$, $n=1$, and $n=5$.
    
    Thus, for $n\in\N$ with $n\ne 1,2,5$, 
    \begin{align*} 
        F(n)
        &amp;=1+2\big(\Num_{a,3/4,b/4,1,2}+\Num_{a,1/4,b/4,1,2}-a+\floor{n/3}-a+n\big)\\
        &amp;=1+2\Num_{\ceil{n/4},3/4,\{-n/4\},1,2}+2\Num_{\ceil{n/4},1/4,\{-n/4\},1,2}+2n+2\floor{n/3}-4\ceil{n/4}.
    \end{align*} 
    We can fill in the missing values by hand. We compute $f(1)=2$, $f(2)=2$, and $f(5)=0$. And by the formula above with $n=4$,  
    \[
        F(4)
        =1+2\Num_{1,3/4,0,1,2}+2\Num_{1,1/4,0,1,2}+4+2\floor{4/3}-0
        =1+2\cdot1+2\cdot1+4+2
        =11.
    \]
    Thus, $F(0)=1$, $F(1)=F(0)+f(1)=1+2=3$, $F(2)=F(1)+f(2)=3+2=5$, and $F(5)=F(4)+f(5)=11+0=11$.
\end{proof}
\begin{figure}[H]
    \centering
    \includegraphics[scale=.6]{x2p2y2e29.eps}
    \includegraphics[scale=.6]{sqrtm2lattice.eps}
    \caption{The 65 lattice points within the ellipse $x^2+2y^2=29$, and the 65 elements of $\Z[\sqrt{-2}]$ with norm at most 29.}
    \label{fig:x^2+2y^2=29}
\end{figure}

\begin{example}\label{ex:x^2+2y^2=29}
    We compute the number of lattice points contained in the ellipse defined by $x^2+2y^2=29$. We have $n=29$, $\ceil{29/4}=8$, and $\{-29/4\}=3/4$.
    
    To compute $\Num_{8,3/4,3/4,1,2}$, we consider the sequence 
    \[
        \FLoor{\frac{8-3/4}{1}+3/4}, \FLoor{\frac{8-3/4}{2}+3/4}, \dots, \FLoor{\frac{8-3/4}{8}+3/4} 
        = 8,4,3,2,2,1,1,1.
    \]
    There are 4 odd numbers, so $\Num_{8,3/4,3/4,1,2}=4$.
    
    To compute $\Num_{8,1/4,3/4,1,2}$, we consider the sequence 
    \[
        \FLoor{\frac{8-3/4}{1}+1/4}, \FLoor{\frac{8-3/4}{2}+1/4}, \dots, \FLoor{\frac{8-3/4}{8}+1/4} 
        = 7,3,2,2,1,1,1,1.
    \]
    There are 6 odd numbers, so $\Num_{8,1/4,3/4,1,2}=6$.
    
    By Corollary~\ref{cor:x^2+2y^2}, the number of lattice points in this ellipse is 
    \begin{align*}
        F(29) 
        &amp;= 1+2\Num_{8,3/4,3/4,1,2}+2\Num_{8,1/4,3/4,1,2}+29+2\floor{29/3}-3 \\
        &amp;= 1+2\cdot4+2\cdot6+29+2\cdot9-3 \\
        &amp;= 65.
    \end{align*}
    See Figure~\ref{fig:x^2+2y^2=29}.
\end{example}

\begin{remark}
    Consider the ring $\Z[\sqrt{-2}]$. For $z=a+b\sqrt{-2}\in\Z[\sqrt{-2}]$, the norm of $z$ is $N(z)=a^2+2b^2$. Thus, Corollary~\ref{cor:x^2+2y^2} gives a formula for the number of elements of $\Z[\sqrt{-2}]$ with norm at most $n$. Following from Example~\ref{ex:x^2+2y^2=29}, we know there are 65 elements of $\Z[\sqrt{-2}]$ with norm at most 29. We visualize these elements in Figure~\ref{fig:x^2+2y^2=29}.
\end{remark}

\section{Acknowledgments}
We wish to thank the anonymous referee for the thorough feedback and thoughtful suggestions. We also wish to thank our colleagues from the PROMYS for Teachers program for helping to create an enthusiastic and supportive mathematical community.

\begin{thebibliography}{99}

\bibitem{Apostol1976}
{T. Apostol,}
{\textit{Introduction to Analytic Number Theory},}
{Undergraduate Texts in Mathematics, Springer-Verlag, 1976.}

\bibitem{Dickson1958}
 {L. E. Dickson,}
 {\textit{Introduction to the Theory of Numbers},}
 {Dover, 1957.}

\bibitem{Grosswald1985}
{E. Grosswald,}
{\textit{Representations of Integers as Sums of Squares},}
{Springer-Verlag, 1985.}

\bibitem{HardyWright1979}
{G. H. Hardy and E. M. Wright,}
{\textit{An Introduction to the Theory of Numbers},}
{The Clarendon Press, Oxford University Press, fifth edition, 1979.}

\bibitem{Huxley2002}
{M. N. Huxley,}
{Integer points, exponential sums and the Riemann zeta function,}
{in \textit{Number Theory for the Millennium {II}}, A K Peters/CRC Press, 2002, pp. 275--290.
}

\bibitem{MSE-floor-summation}
{E. Naslund,}
{Rounding is asymptotically useless?}
{Mathematics Stack Exchange, 2012. Available at \url{https://math.stackexchange.com/q/116687}.}

\bibitem{Rademacher77}
{H. Rademacher,}
{\textit{Lectures on Elementary Number Theory},}
{Robert E.\ Krieger Publishing Co., 1977.}

\bibitem{3b1b-pi-prime-regularities}
{G. Sanderson,}
{Pi hiding in prime regularities,}
{3Blue1Brown, YouTube, 2017. Available at \url{https://youtu.be/NaL\_Cb42WyY}.}

\bibitem{Shor23}
{C. Shor,}
{Reflective numerical semigroups,}
{\textit{Albanian J.\ Math.}} 
{\textbf{17} (2023), 55--82.}

\bibitem{oeis}
    {N. J. A.~Sloane et al.,} 
        {The On-line Encyclopedia of Integer Sequences, 2020.} 
        {Available at \url{https://oeis.org/}.}

\bibitem{sage}
{W. A. Stein et al.,}
{\textit{Sage Mathematics Software (Version 9.5)},}
{The Sage Development Team, 2022. Available at \url{http://www.sagemath.org/}.}
\end{thebibliography}


\bigskip
\hrule
\bigskip

\noindent 2020 \textit{Mathematics Subject Classification}:  Primary 11N37;  Secondary 11P21.

\noindent {\textit{Keywords}:} rounding, lattice point, Gauss circle problem, Dirichlet divisor problem.

\bigskip
\hrule
\bigskip

\noindent (Concerned with sequences 
\seqnum{A014202},
\seqnum{A038589},
\seqnum{A057655},
\seqnum{A059851},
\seqnum{A330926}, and
\seqnum{A363341}.)

\bigskip
\hrule
\bigskip

\vspace*{+.1in}
\noindent
Received June 30 2023;
revised versions received  September 23 2023; January 18 2024.
Published in {\it Journal of Integer Sequences}, January 20 2024.

\bigskip
\hrule
\bigskip

\noindent
Return to
\htmladdnormallink{Journal of Integer Sequences home page}{https://cs.uwaterloo.ca/journals/JIS/}.
\vskip .1in


\end{document}

                                                                                

</pre></body></html>