Content uploaded by Luka Podrug
Author content
All content in this area was uploaded by Luka Podrug on Nov 11, 2023
Content may be subject to copyright.
MATHEMATICAL COMMUNICATIONS 303
Math. Commun. 28(2023), 303–316
Some refinements of formulae involving floor and ceiling
functions
Luka Podrug1,∗and Dragutin Svrtan2
1Faculty of Civil Engineering, University of Zagreb, Kaˇci´ceva 26, HR-10 000 Zagreb
2Department of Mathematics, Faculty of Science, University of Zagreb, Bijeniˇcka cesta
30, HR-10 000 Zagreb
Received April 1, 2023; accepted September 15, 2023
Abstract. The floor and ceiling functions appear often in mathematics and manipulating
sums involving floors and ceilings is a subtle game. Fortunately, the well-known textbook
Concrete Mathematics provides a nice introduction with a number of techniques explained
and a number of single or double sums treated as exercises. For two such double sums we
provide their single-sum analogues. These closed-form identities are given in terms of a
dual partition of the multiset (regarded as a partition) of all b-ary digits of a nonnegative
integer. We also present the double- and single-sum analogues involving the fractional part
function and the shifted fractional part function.
AMS subject classifications: 11A99
Keywords: sum, floor function, ceiling function, fractional part function
1. Introduction
In this paper, we are concerned with computing some sums involving floor and ceiling
functions, presenting several new formulae that refine previously known results. For
the reader’s convenience, we start by stating some basic definitions.
Let xbe any real number. The floor of xis defined as the greatest integer less
than or equal to x, that is, bxc= max {n|n≤x, n ∈Z}. The ceiling of xis the
least integer greater than or equal to x, that is, dxe= min {n|n≥x, n ∈Z}. For
every n∈Zand x∈Rwe have bn+xc=n+bxcand dn+xe=n+dxe. Finally,
the fractional part of xis {x}=x− bxc. We sometimes call bxcthe integer part of
xsince x=bxc+{x}with 0 ≤ {x}<1. For every n∈Zand 0 ≤x < 1 we have
{n+x}=x.
Throughout the paper we use the Iverson notation [4], which encloses a true-or-
false statement Pin brackets, whose result is 1 if the statement is true, and 0 if the
statement is false. For example,
[j=k] = (1,if j=k;
0,if j6=k.
∗Corresponding author. Email addresses: luka.podrug@grad.unizg.hr (L. Podrug),
dragutin.svrtan@gmail.com (D. Svrtan)
https://www.mathos.unios.hr/mc
c
2023 School of Applied Mathematics and Computer Science, University of Osijek
304 L. Podrug and D. Svrtan
Our main result is a closed-form expression for the sum
X
k≥1n+jbk−1
bk,
where b≥2, 0 ≤j < b, and nis any nonnegative integer. The sum is infinite, but
only finitely many of its terms are nonzero, and thus it is a well-defined integer. The
new formula is a refinement of the known identity P
k≥1P
0<j<bjn+j bk−1
bkk=n[3, Ex.
44, p. 44]. In the second part of the paper, we obtain the closed-form expression for
the single-sum ceiling analogue
X
0≤k≤logbxx+jbk
bk+1 ,
and in Section 4, for the following double- and single-sum fractional analogues:
X
0≤k≤logbnX
0<j<bn+jbk
bk+1 ,
X
0≤k≤logbnn+jbk
bk+1 .
2. Sums involving the floor function
We start with a problem which appears as an exercise in the book Concrete Mathe-
matics [2, Ex. 22, p. 97], but which can be traced back to a much older collection of
the 400 best problems [5, Problem 4346, p. 48]. This problem concerns the evalua-
tion of the sum S(n) = P
k≥1n
2k+1
2and we state two most common ways of dealing
with it.
In the first approach, for a fixed integer k, let fk(n) = n
2k+1
2. The function
x→x
2k+1
2is clearly a continuous, monotonically increasing function. If n
2k+1
2=
m∈Nfor some n, then we have fk(n−1) < fk(n). For what value(s) of ndoes this
happen?
n+ 2k−1
2k=m=⇒n= 2k−1(2m−1)
| {z }
odd
.
Hence, fk(n−1) < fk(n), when n=b·2k−1, with bodd. For given n, there is exactly
one bwith that property. So, for fixed n, let bbe odd and such that n=b·2kn−1
for some kn≥1. We have
S(n) = P
k≥1
fk(n) and S(n−1) = P
k≥1
fk(n−1),
Formulae involving floor and ceiling functions 305
and fk(n) = fk(n−1) for every k6=kn. For k=knwe have fkn(n) = fkn(n−1)+ 1,
so S(n) = S(n−1) + 1 and thus by induction S(n) = n.
The second approach to evaluating S(n) (which appears in the original solution)
uses binary expansions. Suppose n’s binary expansion is
n= (cmcm−1· · · c1c0)2,
i.e.,
n=cm2m+cm−12m−1+· · · +c121+c0,
where each ciis either 0 or 1 and the leading bit cmis 1.
We claim that only digits csfor s≥k−1 contribute. To show this, we consider
n
2k+1
2=
P
s≥0
cs2s
2k+1
2
=
X
s≥0
cs2s−k+1
2
=
X
0≤s≤k−1
cs2s−k+X
s≥k
cs2s−k+1
2
=X
s≥k
cs2s−k+
X
0≤s≤k−1
cs2s−k+1
2
=X
s≥k
cs2s−k+ck−1.
By summing over k≥1 we get
X
k≥1n
2k+1
2=X
k≥0
ck+X
k≥1X
s≥k
cs2s−k
=X
k≥0
ck+X
s≥1X
1≤k≤s
cs2s−k
=X
k≥0
ck+X
s≥1
cs
2s−1
2−1
=X
k≥0
ck+X
s≥1
2scs−X
s≥1
cs
=X
s≥0
2scs
=n.
More generally, for every base bwe have the following identity: [3, Ex. 44, p. 44]
X
k≥1X
0<j<bn+jbk−1
bk=n. (1)
306 L. Podrug and D. Svrtan
To prove it, we can use the following replication identity [2, 3.26, p. 85]:
bxc+x+1
m+x+2
m+· · · +x+m−1
m=bmxc
which leads to
X
k≥1X
0<j<bn+jbk−1
bk=X
k≥1X
0<j<bn
bk+j
b
=X
k≥1j n
bk−1k−jn
bkk
=n.
To move toward a new refined result (stated in Theorem 1 below) we need more
notation. For every base b≥2 let n’s b-ary expansion be n= (cmcm−1· · · c0)b, that
is,
n=cmbm+cm−1bm−1+· · · +c1b+c0,
where ci∈ {0,1, . . . , b −1},m=blogbnc, and where the leading b-ary digit cmis
nonzero. Consider the multiset of b-ary digits {c0, c1, . . . , cm}and let sb(n) denote
the sum of all b-ary digits of n, that is,
sb(n) = sb
blogbnc
X
s=0
csbs
=
blogbnc
X
s=0
cs.
Let λ=λ(n, b) = (λ1≥λ2≥ · · · ≥ λm) be the partition containing the b-ary digits
{c0, c1, . . . , cm}in descending order and let λ0=λ0(n, b) = λ0
1≥λ0
2≥ · · · ≥ λ0
b−1
be the transpose of the partition λ. This follows Macdonald’s notation [7]. Note
that λ0
jis the number of b-ary digits greater than or equal to jand, since there are
no digits greater than b−1, we set λ0
bto be 0 . For example, let n= 1024 and b= 3.
We have 1024 = (1101221)3. Then s3(1024) = 8, λ= (2 ≥2≥1≥1≥1≥1≥0)
and λ0= (6 ≥2).
Remark 1. Observe that both λand λ0are partitions of the number sb(n), i.e.,
sb(n) = |λ|=X
0≤j≤m
λj=X
0<j<b
λ0
j.
Theorem 1. For every base b≥2, fixed j,0≤j < b, and for every nonnegative
integer nwe have the following identity:
X
k≥1n+jbk−1
bk=n−sb(n)
b−1+λ0
b−j.(2)
For j= 0 and b=pprime, we obtain the right equality of the well-known number
theoretic formula:
νp(n!) = X
k≥1n
pk=n−sp(n)
p−1,
where νp(m) is the multiplicity of pin the factorization of m.
First, we state and prove an auxiliary result.
Formulae involving floor and ceiling functions 307
Lemma 1. For every base b, let n’s b-ary expansion be n= (cmcm−1· · · c0)bwith
0≤cs≤b−1for every sand 0≤j < b. Then for every k
ck+j
b+ck−1
b2+· · · +c0
bk+1 = [ck+j≥b].
Proof of Lemma 1. Since
ck+j
b+ck−1
b2+· · · +c0
bk+1 ≤2b−2
b+b−1
b2+· · · +b−1
bk+1
=2−2
b+1
b−1
b2+1
b2−1
b3+· · · +1
bk−1
bk+1
=2−1
b−1
bk+1
<2,
the integer part ck+j
b+ck−1
b2+· · · +c0
bk+1 is either 0 or 1.
For ck+j≥bwe have ck+j
b+ck−1
b2+· · · +c0
bk+1 = 1, and if ck+j < b, we have
ck+j≤b−1, thus
0≤ck+j
b+ck−1
b2+· · · +c0
bk+1 ≤b−1
b+b−1
b2+· · · +b−1
bk+1
=1−1
b+1
b−1
bk+1
=1−1
bk+1
= 0.
Proof of Theorem 1. By substituting nwith the b-ary expansion of nand by
using Lemma 1 we obtain
X
k≥1n+jbk−1
bk=X
k≥1n
bk+j
b
=X
k≥1
X
s≥0
csbs
bk+j
b
=X
k≥1
X
s≥k
csbs−k+ck−1+j
b+ck−2
b2+· · · +c0
bk
=X
k≥1X
s≥k
csbs−k+X
k≥1ck−1+j
b+ck−2
b2+· · · +c0
bk
308 L. Podrug and D. Svrtan
=X
k≥1X
s≥k
csbs−k+X
k≥1
[ck−1+j≥b] (by Lemma 1)
=X
s≥1
csb0+b1+· · · +bs−1+X
s≥0
[cs≥b−j]
=X
s≥1
cs·bs−1
b−1+λ0
b−j
=1
b−1
X
s≥1
csbs+c0−c0−X
s≥1
cs
+λ0
b−j
=1
b−1
X
s≥0
csbs−X
s≥0
cs
+λ0
b−j
=n−sb(n)
b−1+λ0
b−j.
The double-sum formula (1) then follows immediately:
Corollary 1. For every base b≥2and for every nonnegative integer nwe have the
following identity:
X
k≥1X
0<j<bn+jbk−1
bk=n.
Proof.By changing the order of summation the left-hand side is equal to:
X
k≥1X
0<j<bn+jbk−1
bk=X
0<j<b X
k≥1n+jbk−1
bk
=X
0<j<b n−sb(n)
b−1+λ0
b−j(by Theorem 1)
=n−sb(n)+(λb−1+· · · +λ1)
=n.
3. Sums involving ceiling function
Now we turn our attention to the well-known ceiling analogue of Formula (1). A
double sum [2, Ex. 39, p. 99]
X
0≤k≤logbxX
0<j<bx+jbk
bk+1
is equal to (b−1) (blogbxc+ 1) + dxe − 1 for every real number x≥1 and every
integer b≥2.
Formulae involving floor and ceiling functions 309
More generally, we state the following refinement of this formula. Again, let
b≥2 be any base, let n:= dxeand let n= (cmcm−1· · · c0)bbe n’s b-ary expansion,
λ=λ(n, b) and λ0=λ0(n, b), as before, partition of the multiset of the b-ary digits
of nand its transpose. Note that m=blogbncis the position of the leading digit in
n’s b-ary expansion. We also define νb(n) := max k|bk\n. We shall evaluate the
sum for every fixed j, 0 < j < b.
Theorem 2. For every base b≥2, fixed j,0< j < b, and for every real x≥1we
have the following identity:
X
0≤k≤logbxx+jbk
bk+1 =n−sb(n)
b−1+m+λ0
b−j+cνb(n)6=b−j,(3)
where n=dxeand m=blogbncis the position of the leading digit in n’s b-ary
expansion.
Proof.Let b≥2, 0 < j < b and 0 ≤k≤logbxbe integers and f(x) = x+j bk
bk+1 .
Then fis a continuous, monotonically increasing function. Suppose f(x) = z∈Z.
Then we have x=zbk+1 −jbk∈Zand, since fsatisfies the necessary conditions [2,
(3.10), p. 71], we can conclude that df(x)e=df(dxe)efor all x∈R. Then
X
0≤k≤logbxx+jbk
bk+1 =X
0≤k≤logbxn+jbk
bk+1 .
Suppose n’s b-ary expansion is
n= (cmcm−1· · · c1c0)b,
i.e.,
n=cmbm+cm−1bm−1+· · · +c1b1+c0,
where each cs∈ {0,1, . . . , b −1}and the leading digit cmis nonzero.
X
0≤k≤logbxx+jbk
bk+1 =X
0≤k≤logbxn
bk+1 +j
b
=X
0≤k≤logbx
X
s≥0
csbs
bk+1 +j
b
=X
0≤k≤logbx
X
s≥k+1
csbs
bk+1 +X
0≤s≤k
csbs
bk+1 +j
b
=X
0≤k≤logbxX
s≥k+1
csbs−k−1
+X
0≤k≤logbxck+j
b+ck−1
b2+· · · +c0
bk+1 .
310 L. Podrug and D. Svrtan
By changing the order of summation, the first (double) sum is equal to:
X
0≤k≤logbxX
s≥k+1
csbs−k−1=X
1≤s≤logbx+1
csbs−1X
0≤k≤s−1
b−k
=X
1≤s≤logbx+1
csbs−1·1−b−s
1−b−1
=X
1≤s≤logbx+1
cs·bs−1−b−1
1−b−1
=X
1≤s≤logbx+1
cs·bs−1
b−1
=1
b−1
X
1≤s≤logbx+1
csbs−X
1≤s≤logbx+1
cs
=n−sb(n)
b−1.
The second (single) sum is bounded by
ck+j
b+ck−1
b2+· · · +c0
bk+1 ≤2b−2
b+b−1
b2+· · · +b−1
bk+1
=2−2
b+1
b−1
b2+1
b2−1
b3+· · · +1
bk−1
bk+1
=2−1
b−1
bk+1
≤2.
Hence, ck+j
b+ck−1
b2+· · · +c0
bk+1 is either 1 or 2.
For ck+j > b we have ck+j
b+ck−1
b2+· · · +c0
bk+1 = 2. For ck+j < b we have
ck+j≤b−1 and
1≤ck+j
b+ck−1
b2+· · · +c0
bk+1 ≤b−1
b+b−1
b2+· · · +b−1
bk+1
=1−1
b+1
b−1
b2+1
b2−1
b3+· · · +1
bk−1
bk+1
=1−1
bk−1
= 1.
For ck+j=band ck−1=ck−2=· · · =c0= 0 we have that bkexactly divides n, so
νb(n) = kand ck+j
b+ck−1
b2+· · · +c0
bk+1 = 1.
Formulae involving floor and ceiling functions 311
Furthermore, for ck+j=band at least one cs>0 with 0 ≤s≤k−1 we have
ck+j
b+ck−1
b2+· · · +c0
bk+1 = 2. So:
X
0≤k≤logbxck+j
b+ck−1
b2+· · · +c0
bk+1 =m+1+λ0
b−j−cνb(n)=b−j
=m+λ0
b−j+cνb(n)6=b−j.
Finally, we have
X
0≤k≤logbxx+jbk
bk+1 =n−sb(n)
b−1+m+λ0
b−j+cνb(n)6=b−j.
Corollary 2. For every base b≥2and for every real x≥1we have the following
identity:
X
0≤k≤logbxX
0<j<bx+jbk
bk+1 = (b−1) (m+ 1) + n−1,
where n=dxeand m=blogbncis the position of the leading digit in n’s b-ary
expansion.
Proof.
X
0≤k≤logbxX
0<j<bx+jbk
bk+1 =X
0<j<b X
0≤k≤logbxx+jbk
bk+1
=X
0<j<b n−sb(n)
b−1+m+1+λ0
b−j−cνb(n)=b−j
=n−sb(n)+(b−1) (m+ 1)
+X
0<j<b λ0
b−j−cνb(n)=b−j.
It remains to prove that
X
0<j<b λ0
b−j−cνb(n)=b−j=sb(n)−1.
By Remark 1, P
0<j<b
λ0
b−j=sb(n). We can also see that
X
0<j<b cνb(n)=b−j= 1.
This is true because there is exactly one kthat νb(n) = k. Since cνb(n)>0 and
jranges from 1 to b−1, the required digit that makes expression cνb(n)=b−j
equal to 1 must also occur and also exactly once.
312 L. Podrug and D. Svrtan
Finally, we have
X
0≤k≤logbxX
0<j<bx+jbk
bk+1 =n−sb(n)+(b−1) (m+ 1)
+X
0<j<b λ0
b−j−cνb(n)=b−j
=n−sb(n)+(b−1) (m+ 1) + sb(n)−1
=(b−1) (m+ 1) + n−1.
4. Sums involving fractional part function
In the following theorem, we obtain the fractional analogue of the floor and ceiling
formulae (2) and (3). Esser, Tao, Totaro, and Wang [1] considered signed fractional
function g(x) = x+1
2−xwhich takes values in −1
2,1
2, and proved that
r
X
j=0
gk
2j+ 2gk
2r+1 = 1.
Here we give a formula for a sum where a standard fractional part function is used.
Theorem 3. For every base b≥2, fixed j,0< j < b, and for every nonnegative
integer nwe have the following identity:
X
0≤k≤logbnn+jbk
bk+1 =1
b−1sb(n)−n
bm+1 + (m+ 1)j
b−λ0
b−j,
where m=blogbncis the position of the leading digit in n’s b-ary expansion.
Proof.Consider n’s b-ary expansion as before.
X
0≤k≤logbnn+jbk
bk+1 =X
0≤k≤logbn
X
s≥0
csbs
bk+1 +j
b
=X
0≤k≤logbn
X
s≥k+1
csbs
bk+1 +X
0≤s≤k
csbs
bk+1 +j
b
=X
0≤k≤logbn
X
0≤s≤k
csbs
bk+1 +j
b
.
Formulae involving floor and ceiling functions 313
The inner sum is bounded by
ck+j
b+ck−1
b2+· · · +c0
bk+1 ≤2b−2
b+b−1
b2+· · · +b−1
bk+1
= 2 −1
b−1
bk+1
<2.
So, (P
0≤s≤k
csbs
bk+1 +j
b)is either P
0≤s≤k
csbs
bk+1 +j
bor P
0≤s≤k
csbs
bk+1 +j
b−1. For ck+j≥b
we have P
0≤s≤k
csbs
bk+1 +j
b≥1 and (P
0≤s≤k
csbs
bk+1 +j
b)=P
0≤s≤k
csbs
bk+1 +j
b−1. For ck+j < b
we have ck+j≤b−1 and
ck+j
b+ck−1
b2+· · · +c0
bk+1 ≤b−1
b+b−1
b2+· · · +b−1
bk+1
= 1 −1
bk−1
<1.
We conclude that (P
0≤s≤k
csbs
bk+1 +j
b)=P
0≤s≤k
csbs
bk+1 +j
b.
Therefore,
X
0≤k≤logbnn+jbk
bk+1 =X
0≤k≤logbn
X
0≤s≤k
csbs
bk+1 +j
b−[ck≥b−j]
=X
0≤s≤logbn
csX
s≤k≤logbn
bs−k−1+ (blogbnc+ 1) j
b−λ0
b−j
=X
0≤s≤logbn
cs·b−1−bs−blogbnc−2
1−1
b
+ (m+ 1)j
b−λ0
b−j
=X
0≤s≤logbn
cs·1−bs−m−1
b−1+ (m+ 1)j
b−λ0
b−j
=P
0≤s≤logbn
cs
b−1−P
0≤s≤logbn
csbs
bm+1(b−1) + (m+ 1) j
b−λ0
b−j
=1
b−1sb(n)−n
bm+1 + (m+ 1)j
b−λ0
b−j.
Finally, by simple summation of the formula in Theorem 3 over 0 < j < b, the
closed-form formula for the double-sum fractional analogue reads:
314 L. Podrug and D. Svrtan
Corollary 3. For every base b≥2and for every nonnegative integer nwe have the
following identity:
X
0≤k≤logbnX
0<j<bn+jbk
bk+1 = (m+ 1)b−1
2−n
bm+1 ,
where m=blogbncis the position of the leading digit in n’s b-ary expansion.
Proof.By changing the order of summation the left-hand side is equal to:
X
0<j<b X
0≤k≤logbnn+jbk
bk+1 =X
0<j<b 1
b−1sb(n)−n
bm+1 + (m+ 1)j
b−λ0
b−j
=sb(n)−n
bm+1 + (m+ 1)b(b−1)
2b−sb(n)
= (m+ 1)b−1
2−n
bm+1 .
Yet another among 400 best problems [5, Problem 4375, p. 50] concerns the
summation of the following function:
((x)) = (x− bxc − 1
2={x} − 1
2,if xis not an integer;
0,if xis an integer.
This function is basic for the definition of the well-known Dedekind sum [6, Def.
5.1, p. 92]. Here we can easily obtain the closed-form analogues of single and double
sums for this function.
Remark 2. For 0≤k≤logbnand fixed j,0< j < b, only one among the fractions
n+jbk
bk+1
is an integer.
Proof.If νb(n) = k, then ck6= 0 and n=
m
P
s=k
csbs,where m=blogbnc. Then
n+jbk
bk+1 =ck+j
b+ck+1 +ck+2b+· · · +cmbm−k−1.
Then ck=b−jgives the only integer value of the fraction above.
Theorem 4. For every base b≥2, fixed j,0< j < b, and for every nonnegative
integer nwe have the following identity:
X
0≤k≤logbnn+jbk
bk+1 =1
b−1sb(n)−n
bm+1
+ (m+ 1) j
b−1
2−λ0
b−j+1
2cνb(n)=b−j,
where m=blogbncis the position of the leading digit in n’s b-ary expansion.
Formulae involving floor and ceiling functions 315
Proof.Consider n’s b-ary expansion as before.
X
0≤k≤logbnn+jbk
bk+1
=X
0≤k≤logbnn+jbk
bk+1 −X
0≤k≤logbn
1
2+1
2cνb(n)=b−j
=1
b−1sb(n)−n
bm+1 + (m+ 1)j
b−λ0
b−j−m+ 1
2+1
2cνb(n)=b−j
=1
b−1sb(n)−n
bm+1 + (m+ 1) j
b−1
2−λ0
b−j+1
2cνb(n)=b−j.
Corollary 4. For every base b≥2and for every nonnegative integer nwe have the
following identity:
X
0≤k≤logbnX
0<j<bn+j bk
bk+1 =1
2−n
bm+1 ,
where m=blogbncis the position of the leading digit in n’s b-ary expansion.
Proof.Note that by Remark 2, the sum P
0<j<b
1
2cνb(n)=b−jis equal to 1
2.
X
0≤k≤logbnX
0<j<bn+j bk
bk+1
=X
0<j<b 1
b−1sb(n)−n
bm+1 + (m+ 1) j
b−1
2−λ0
b−j+1
2cνb(n)=b−j
=sb(n)−n
bm+1 + (m+ 1) b(b−1)
2b−b−1
2−sb(n) + X
0<j<b
1
2cνb(n)=b−j
=1
2−n
bm+1 .
We hope that our summation techniques may be applied further in number the-
ory, approximation theory or elsewhere.
References
[1] L. Esser, T. Tao, B. Totaro, C. Wang,Optimal Sine and Sawtooth Inequalities,
J. Fourier Anal. Appl., Paper No. 14, 28(2002).
[2] R. L. Graham, D. E. Knuth, O. Patashnik,Concrete Mathematics, Addison-
Wesley, 1994.
316 L. Podrug and D. Svrtan
[3] D. E. Knuth,The Art of Computer Programming, Addison-Wesley, 1997.
[4] D. E. Knuth,Two notes on notation, Amer. Math. Monthly 99 (1992), 403–422.
[5] H. Eves, E. P. Starke,The Otto Dunkel Memorial Problem Book, Supplement to
the Amer. Math. Monthly 64(1957).
[6] F. Hirzebruch, D. Zagier,The Atiyah-Singer Theorem and Elementary Number
Theory, Publish or Perish Inc., 1974.
[7] I. G. Macdonald,Symmetric Functions and Hall Polynomials, Oxford University
Press Inc., 1995.