An Alternating Sum of the Floor Function of Square Roots

Marc Chamberland Department of Mathematics Grinnell College Grinnell, IA 50112 USA

                 chamberl@grinnell.edu

Karl Dilcher Department of Mathematics and Statistics Dalhousie University Halifax, Nova Scotia, B3H 4R2 Canada

                dilcher@mathstat.dal.ca

Abstract

We show that the alternating sum of the floor function of \sqrt{jn}, with j ranging from 1 to n, has an easy evaluation for all odd integers n ≥ 1. This is in contrast to known non-alternating sums of the same type that hold only for a class of primes. The proof is elementary and was suggested by an AI model. To put this result in perspective, we also prove an asymptotic expression for the analogous sum without the floor function.

1 Introduction

The famous two-volume “Problems and Theorems in Analysis” by Pólya and Szegő contains the following curious identity: if p ≡ 1 (mod 4) is a prime, then

∑_{j=1}^{\frac{p−1}{4}} ⌊\sqrt{jp}⌋ = \frac{p^{2} − 1}{12},  (1)

where the floor function of x ∈ ℝ is the integer ⌊x⌋ defined by ⌊x⌋ ≤ x < ⌊x⌋ + 1. Further remarks on this identity can be found in Section 4 below.

It is a natural question to ask whether there are any similar results for alternating sums of the type (1). While no such identity seems to exist for the summation limit (p − 1)/4, numerical experiments led us to the following identity.

Theorem 1. For any odd integer n ≥ 1 we have

∑_{j=1}^{n}(−1)^{j+1} ⌊\sqrt{jn}⌋ = \frac{n + 1}{2}.  (2)

This result is surprising for at least two reasons. First, it holds for all odd n ≥ 1, and not just for primes of a certain form, as is the case in (1). Second, using standard methods from analytic number theory, we can prove the following estimate, valid for any odd integer n ≥ 1:

∑_{j=1}^{n}(−1)^{j+1}\sqrt{jn} = \frac{n}{2} + (1 − 2\sqrt{2}) ζ(−\frac{1}{2})\sqrt{n} + \frac{1}{8} + O(\frac{1}{n}) (n → ∞),  (3)

where C := (1−2\sqrt{2})ζ(−1/2) ≃ 0.3801. Comparing (3) with (2), we see that by putting \sqrt{jn} between the floor brackets, the error term C\sqrt{n} + 1/8 + O(1/n) turns into the surprisingly neat constant 1/2.

It is the main purpose of this paper to prove the identity (2); this is done in Section 2. In Section 3 we prove the estimate (3), and we conclude this paper with a few remarks in Section 4.

2 Proof of Theorem 1

The following proof was suggested by the AI model Gemini [5]. It was then verified, simplified and rewritten by us.

Proof of Theorem 1. We rewrite the positive integer ⌊\sqrt{jn}⌋ as a sum and then change the order of summation, obtaining

∑_{j=1}^{n}(−1)^{j+1} ⌊\sqrt{jn}⌋ = ∑_{j=1}^{n}(−1)^{j+1} ∑_{k=1}^{⌊\sqrt{jn}⌋} 1

= ∑_{k=1}^{n} ∑_{j=⌈k^{2}/n⌉}^{n}(−1)^{j+1},  (4)

where we have used the fact that k ≤ \sqrt{jn} is equivalent to j ≥ k^{2}/n. Next, when ⌈k^{2}/n⌉ is odd, then the first summand in the inner sum on the right of (4) is 1, followed by an equal number of summands −1 and 1. When ⌈k^{2}/n⌉ is even, the summands all cancel each other, and therefore the inner sum is 1 when ⌈k^{2}/n⌉ is odd and is 0 otherwise. Hence we have with (4),

∑_{j=1}^{n}(−1)^{j+1} ⌊\sqrt{jn}⌋ = #\{1 ≤ k ≤ n | ⌈k^{2}/n⌉ is odd\}.  (5)

where as usual #A denotes the cardinality of a finite set A. When k = n, then ⌈k^{2}/n⌉ = n is odd. Next, we note that

⌈\frac{(n − k)^{2}}{n} ⌉ = ⌈n − 2k + \frac{k^{2}}{n} ⌉ = n − 2k + ⌈\frac{k^{2}}{n} ⌉ .

Since n is odd, ⌈(n − k)^{2}/n⌉ and ⌈k^{2}/n⌉ have opposite parities, and for 1 ≤ k ≤ (n − 1)/2, they are exactly all the remaining elements of the set in (5). So finally, by (5) we have

∑_{j=1}^{n}(−1)^{j+1} ⌊\sqrt{jn}⌋ = 1 + \frac{n − 1}{2} = \frac{n + 1}{2},

which was to be shown.

To conclude this section, we briefly explain an alternative approach to a proof of Theorem 1 which may be of interest in its own right.

The summand for j = n in (2) is clearly 1, and we consider the differences

d_{n}(ℓ) := ⌊\sqrt{2ℓn}⌋ − ⌊\sqrt{(2ℓ − 1)n}⌋ ,  1 ≤ ℓ ≤ \frac{n − 1}{2}.  (6)

Then the statement of Theorem 1 is equivalent to

∑_{ℓ=1}^{\frac{n−1}{2}} d_{n}(ℓ) = \frac{n − 1}{2}  (n odd).  (7)

The approach in question is now best explained by the following example. Let n = 33. Table 1 shows the distribution of the values of d_{n}(ℓ).

\begin{matrix}ℓ & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 \\ d_{33}(ℓ) & 3 & 2 & 2 & 1 & 1 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 1 & 1 & 1 & 1 \end{matrix}

Table 1: d_{33}(ℓ) for 1 ≤ ℓ ≤ 16.

Here the value d_{33}(1) = 3 corresponds to the two consecutive zeros for ℓ = 10 and 11, while d_{33}(2) = 2 corresponds to d_{33}(8) = 0 and d_{33}(3) = 2 to d_{33}(6) = 0. This behavior is typical and is made more explicit in the following statement.

Conjecture 2. Let n ≥ 1 be an odd integer, and suppose that δ := d_{n}(λ) ≥ 2 for some λ ≥ 1. Then each such λ corresponds to δ −1 consecutive integers ℓ_{λ}, …, ℓ_{λ} +δ −2 such that d_{n}(ℓ_{λ} + j) = 0 for j = 0, …, δ − 2. Furthermore, the sets of these zero values are disjoint.

This conjecture implies (7) and thus Theorem 1 since each of the sequences of zeros is filled in by the “surplus” given by the corresponding value of δ.

Our as yet incomplete proof of Conjecture 2 relies on a sequence of rather complicated technical lemmas. In view of the above complete proof of Theorem 1, we did not pursue this any further.

3 Proof of Identity (3)

We wish to find an asymptotic estimate for the sum

S(n) := ∑_{j=1}^{n}(−1)^{j+1}\sqrt{jn}

as n → ∞ and n is odd. Factoring out \sqrt{n} and letting n = 2m + 1, we consider

∑_{j=1}^{n}(−1)^{j+1}\sqrt{j} = ∑_{j=1}^{n} \sqrt{j} − 2 ∑_{k=1}^{m} \sqrt{2k} = A(n) − 2\sqrt{2}A(m),  (8)

where

A(M) = ∑_{r=1}^{M} \sqrt{r}.

The Euler-Maclaurin summation formula (see, e.g., [3, pp. 22ff.]) allows us to write

A(M) = \frac{2}{3}M^{3/2} + \frac{1}{2}M^{1/2} + ζ(−1/2) + \frac{1}{24}M^{−1/2} + O(M^{−3/2}).  (9)

Using the expansions

(\frac{n − 1}{2})^{3/2} = \frac{\sqrt{2}}{4}n^{3/2} − \frac{3\sqrt{2}}{8}\sqrt{n} + \frac{3\sqrt{2}}{32} \frac{1}{\sqrt{n}} + O(n^{−3/2}),
(\frac{n − 1}{2})^{1/2} = \frac{\sqrt{2}}{2}\sqrt{n} − \frac{\sqrt{2}}{4} \frac{1}{\sqrt{n}} + O(n^{−3/2}),
(\frac{n − 1}{2})^{−1/2} = \begin{matrix}√ & \overline{2} \\ √ & \overline{n} \end{matrix} + O(n^{−3/2}),

we obtain with (9),

A(n) − 2\sqrt{2}A(m) = \frac{2}{3}n^{3/2} + \frac{1}{2}n^{1/2} + ζ(−1/2) + \frac{1}{24}n^{−1/2} + O(n^{−3/2})

− 2\sqrt{2} (\frac{2}{3} (\frac{n − 1}{2})^{3/2} + \frac{1}{2} (\frac{n − 1}{2})^{1/2} + ζ(−1/2)

+\frac{1}{24} (\frac{n − 1}{2})^{−1/2} + O ((\frac{n − 1}{2})^{−3/2}))

= \frac{1}{2}\sqrt{n} + (1 − 2\sqrt{2}) ζ(−1/2) + \frac{1}{8\sqrt{n}} + O (n^{−3/2}) .

With (8), this implies

S(n) = \frac{n}{2} + (1 − 2\sqrt{2}) ζ(−1/2)\sqrt{n} + \frac{1}{8} + O (\frac{1}{n}) ,

as desired.

4 Further remarks

1. Pólya and Szegő attribute the identity (1) to Bouniakowski [1], whose name is better known in its English transliteration Bunyakovsky. In [6] the identity (1) is the last of several exercises that use the technique of counting lattice points (Part 8, Problem 20). A different and more recent proof was given by Shirali [7].

While the identity (1) does not hold for primes p ≡ 3 (mod 4), there is in fact an evaluation in this case which involves the class number of the imaginary quadratic field ℚ(\sqrt{−p}). This has been proved in [2], along with several other related results, all extending (1).

2. Since the summands in the identity (2) have little or no arithmetic structure, we cannot expect any classical inversion formula, such as Möbius inversion, to apply here. However, the curious identity

⌊\sqrt{k}⌋ = ∑_{d=1}^{k} λ(d) ⌊\frac{k}{d}⌋ ,  (10)

which appears in [4, p. 50], could be considered an inversion of the identity (2). Here λ(n) is the well-known Liouville function, defined by

λ(n) = (−1)^{Ω(n)},

where Ω(n) is the number of all prime divisors of n, counting multiplicities. We have not been able to use the identity (10) in the study of sums such as (2).

5 Acknowledgments

We wish to thank Luc Chamberland for his hearty encouragement to use Google Gemini in our explorations. We also thank Henri Cohen for suggestions and insight that simplified our analysis in Section 3.

References

[1] V. Bouniakowski, Démonstration d’un théorème relatif à la fonction E(x), C. R. Acad. Sci. Paris 94 (1882), 1459–1461.

[2] M. Chamberland and K. Dilcher, Sums of the floor function related to class numbers of imaginary quadratic fields. Preprint. Available at http://arxiv.org/abs/2510.04387.

[3] H. Cohen, Number Theory. Volume II: Analytic and Modern Tools, Springer, 2007.

[4] J.-M. De Koninck and N. Doyon, The Life of Primes in 37 Episodes, American Mathematical Society, 2021.

[5] Gemini, Google, gemini.google.com. Accessed July 3, 2025.

[6] G. Pólya and G. Szegő, Problems and Theorems in Analysis. Vol. II. Theory of Functions, Zeros, Polynomials, Determinants, Number Theory, Geometry. Revised and enlarged translation by C. E. Billigheimer of the fourth German edition, Springer, 1976.

[7] S. A. Shirali, A family portrait of primes—A case study in discrimination, Math. Mag. 70 (1997), 263–272.

2020 Mathematics Subject Classification: Primary 11A25; Secondary 11B83. Keywords: alternating sum, floor function, square root, asymptotics.

(Concerned with sequences \underline{A000196} and \underline{A008836}.)

Received October 30 2025; revised versions received October 31 2025; March 20 2026. Published in Journal of Integer Sequences, March 21 2026.

Return to Journal of Integer Sequences home page.