The floor function strips away the fractional part of a number. It turns continuous quantities into discrete ones — and that is exactly what counting problems need.
How many multiples of 7 are there between 1 and 100?
You could list them: 7, 14, 21, ..., 98. Count: 14.
Or you could compute ⌊100/7⌋=14 directly.
The floor function is the bridge between division and counting. Every time a problem asks "how many integers satisfy...", the floor function is either the answer or the tool that finds it.
The definition
The floor of a real number x, written ⌊x⌋, is the largest integer that does not exceed x.
⌊x⌋=max{n∈Z:n≤x}
Equivalently: ⌊x⌋=n where n is the unique integer satisfying n≤x<n+1.
Examples:
⌊3.7⌋=3
⌊5⌋=5
⌊−2.3⌋=−3 (not −2 — the floor goes down)
⌊π⌋=3
⌊−π⌋=−4
The fractional part is defined as {x}=x−⌊x⌋. Always satisfies 0≤{x}<1.
Basic properties
P1.⌊x⌋≤x<⌊x⌋+1
P2.⌊x⌋=x⟺x is an integer.
P3.⌊x+n⌋=⌊x⌋+n for any integer n.
Proof. Adding an integer shifts x without changing its fractional part. ■
P4.⌊x⌋+⌊y⌋≤⌊x+y⌋≤⌊x⌋+⌊y⌋+1
Proof. Write x=⌊x⌋+{x} and y=⌊y⌋+{y}. Then x+y=(⌊x⌋+⌊y⌋)+({x}+{y}). Since 0≤{x}+{y}<2, the floor of x+y is either ⌊x⌋+⌊y⌋ or ⌊x⌋+⌊y⌋+1. ■
P5.⌊x/n⌋=⌊⌊x⌋/n⌋ for positive integer n.
This one is subtle but very useful — you can take the floor inside or outside, result is the same.
Common mistake.⌊x+y⌋=⌊x⌋+⌊y⌋ in general. Example: ⌊0.6+0.7⌋=⌊1.3⌋=1 but ⌊0.6⌋+⌊0.7⌋=0.
Counting with the floor function
Multiples of d up to n: The number of positive multiples of d that do not exceed n is ⌊n/d⌋.
Proof. The multiples are d,2d,3d,… The largest one ≤n is d⋅⌊n/d⌋, so there are ⌊n/d⌋ of them. ■
Integers in an interval: The number of integers in [a,b] is ⌊b⌋−⌈a⌉+1, where ⌈a⌉=−⌊−a⌋ is the ceiling function.
For integers a≤b: count is b−a+1.
Legendre's formula — highest power of a prime in n!
Theorem. The largest power of prime p dividing n! is:
vp(n!)=∑k=1∞⌊pkn⌋
(The sum is finite since ⌊n/pk⌋=0 for pk>n.)
Why. Among 1,2,…,n:
⌊n/p⌋ multiples of p — each contributes at least one factor of p
⌊n/p2⌋ multiples of p2 — each contributes an extra factor
⌊n/p3⌋ multiples of p3 — each contributes yet another
Application. Number of trailing zeros in n! = v5(n!) (since v2>v5 always, pairs of 2 and 5 form 10s).
Trailing zeros in 100!: ⌊100/5⌋+⌊100/25⌋=20+4=24.
Hermite's identity
⌊x⌋+⌊x+n1⌋+⌊x+n2⌋+⋯+⌊x+nn−1⌋=⌊nx⌋
Proof. Write x=m+{x} where m=⌊x⌋. The left side shifts by integers summing to m⋅n plus contributions from the fractional parts. The fractional part {x} falls in exactly one interval [k/n,(k+1)/n), and the identity reduces to a counting argument on the fractional parts. ■
Special case (n=2): ⌊x⌋+⌊x+21⌋=⌊2x⌋.
Worked problems
Problem 1. How many integers from 1 to 1000 are divisible by 3 but not by 7?
Divisible by 3: ⌊1000/3⌋=333.
Divisible by both 3 and 7 (i.e., by 21): ⌊1000/21⌋=47.
Answer: 333−47=286.
Problem 2. Find the number of trailing zeros in 50!.
⌊50/5⌋+⌊50/25⌋=10+2=12.
Problem 3. Prove: ⌊n⌋ equals the number of perfect squares ≤n.
Perfect squares ≤n: 12,22,…,k2 where k2≤n<(k+1)2. So k=⌊n⌋. ■
Problem 4. Find k=1∑100⌊k⌋.
⌊k⌋=m when m2≤k<(m+1)2, i.e., for 2m+1 values of k.
∑k=1100⌊k⌋=∑m=19m⋅(2m+1)+10⋅1
(For m=1 to 9: each value holds for 2m+1 integers. For m=10: only k=100.)
The floor function's most important application in this thread: counting lattice points — integer coordinate points — under curves. That's where divisor counting and hyperbola geometry meet, in Counting Lattice Points.