Math Core

Module 3.7 · Number Theory

Floor functions

The floor function turns up all over the AMC 10 and 12: in equations like x⌊x⌋=50x \lfloor x \rfloor = 50, in long sums like ⌊1⌋+⌊2⌋+⋯+⌊100⌋\lfloor \sqrt 1 \rfloor + \lfloor \sqrt 2 \rfloor + \dots + \lfloor \sqrt{100} \rfloor, and in counting how many different values an expression takes. The tools are few: split xx into integer and fractional parts, group terms where the floor is constant, and pair terms that add up nicely.

Integer and fractional parts

Definition

Floor and fractional part

⌊x⌋\lfloor x \rfloor is the greatest integer less than or equal to xx. The fractional part is {x}=x−⌊x⌋\{x\} = x - \lfloor x \rfloor, so 0≤{x}<10 \le \{x\} \lt 1 and x=⌊x⌋+{x}x = \lfloor x \rfloor + \{x\}.

Watch negatives: ⌊−2.3⌋=−3\lfloor -2.3 \rfloor = -3, not −2-2. The single most useful restatement is

⌊x⌋=n  ⟺  n≤x<n+1(n an integer).\lfloor x \rfloor = n \iff n \le x \lt n + 1 \qquad (n \text{ an integer}).

To solve an equation with a floor, name the floor: set n=⌊x⌋n = \lfloor x \rfloor, solve for xx in terms of nn, and then impose n≤x<n+1n \le x \lt n + 1 to find which nn are allowed.

A few facts you'll use constantly:

  • ⌊x+m⌋=⌊x⌋+m\lfloor x + m \rfloor = \lfloor x \rfloor + m for any integer mm.
  • ⌊nd⌋\left\lfloor \dfrac{n}{d} \right\rfloor is the number of multiples of dd from 11 to nn (you used this in Legendre's formula).
  • ⌊x⌋+⌊y⌋≤⌊x+y⌋≤⌊x⌋+⌊y⌋+1\lfloor x \rfloor + \lfloor y \rfloor \le \lfloor x + y \rfloor \le \lfloor x \rfloor + \lfloor y \rfloor + 1.

Sums of floors

Group by value. In ∑⌊k⌋\sum \lfloor \sqrt{k} \rfloor, the value is mm for every kk from m2m^2 to (m+1)2−1(m+1)^2 - 1, which is 2m+12m + 1 values of kk. So instead of adding 100100 terms, you add about 1010 blocks.

Pair up. If gcd⁡(a,n)=1\gcd(a, n) = 1 and 1≤k≤n−11 \le k \le n - 1, then akn\dfrac{ak}{n} is never an integer, and

⌊akn⌋+⌊a(n−k)n⌋=a−1,\left\lfloor \frac{ak}{n} \right\rfloor + \left\lfloor \frac{a(n-k)}{n} \right\rfloor = a - 1,

because the two fractions add up to exactly aa and neither is an integer. Pairing kk with n−kn - k gives the following.

Two floor-sum tools

  1. Grouping: ⌊f(k)⌋\lfloor f(k) \rfloor is constant on blocks of kk; count the size of each block and multiply.
  2. Pairing: if gcd⁡(a,n)=1\gcd(a, n) = 1, then ∑k=1n−1⌊akn⌋=(a−1)(n−1)2\displaystyle\sum_{k=1}^{n-1} \left\lfloor \frac{ak}{n} \right\rfloor = \frac{(a-1)(n-1)}{2}.

Counting distinct values

How many different values does ⌊k2N⌋\left\lfloor \dfrac{k^2}{N} \right\rfloor take? While consecutive values of k2N\dfrac{k^2}{N} differ by less than 11 (that is, 2k+1<N2k + 1 \lt N), the floor can't skip any integer, so every integer in the range appears. Once they differ by at least 11, every new kk gives a new value. Split the range at that point and count each part.

Worked example: An equation with a floor

Find the positive real number xx with x⌊x⌋=27x \lfloor x \rfloor = 27.

If 0<x<10 \lt x \lt 1 the product is 00, so x≥1x \ge 1. Let n=⌊x⌋≥1n = \lfloor x \rfloor \ge 1. Then x=27nx = \dfrac{27}{n}, and you need n≤27n<n+1n \le \dfrac{27}{n} \lt n + 1, that is n2≤27<n2+nn^2 \le 27 \lt n^2 + n. Only n=5n = 5 works: 25≤27<3025 \le 27 \lt 30. So x=275=5.4x = \dfrac{27}{5} = 5.4. Check: 5.4⋅5=275.4 \cdot 5 = 27.

Worked example: Grouping

Find ⌊1⌋+⌊2⌋+⋯+⌊100⌋\lfloor \sqrt{1} \rfloor + \lfloor \sqrt{2} \rfloor + \dots + \lfloor \sqrt{100} \rfloor.

For m=1,…,9m = 1, \dots, 9, the value mm appears 2m+12m + 1 times, and ⌊100⌋=10\lfloor \sqrt{100} \rfloor = 10 appears once. So the sum is

∑m=19m(2m+1)+10=2⋅285+45+10=625,\sum_{m=1}^{9} m(2m + 1) + 10 = 2 \cdot 285 + 45 + 10 = 625,

using 12+⋯+92=2851^2 + \dots + 9^2 = 285 and 1+⋯+9=451 + \dots + 9 = 45.

Worked example: Pairing

Find ∑k=130⌊7k31⌋\displaystyle\sum_{k=1}^{30} \left\lfloor \frac{7k}{31} \right\rfloor.

gcd⁡(7,31)=1\gcd(7, 31) = 1, so pairing kk with 31−k31 - k gives 1515 pairs, each adding to 7−1=67 - 1 = 6. The sum is 15⋅6=9015 \cdot 6 = 90, matching (7−1)(31−1)2=90\dfrac{(7-1)(31-1)}{2} = 90.

Worked example: Counting distinct values

How many distinct numbers are in the list ⌊12100⌋,⌊22100⌋,…,⌊1002100⌋\left\lfloor \dfrac{1^2}{100} \right\rfloor, \left\lfloor \dfrac{2^2}{100} \right\rfloor, \dots, \left\lfloor \dfrac{100^2}{100} \right\rfloor?

Consecutive terms of k2100\dfrac{k^2}{100} differ by 2k+1100\dfrac{2k + 1}{100}, which is less than 11 for k≤49k \le 49. So from k=1k = 1 to k=50k = 50 the floors climb from 00 to 2525 without skipping: 2626 values. From k=50k = 50 on the gaps are at least 1.011.01, so k=51,…,100k = 51, \dots, 100 each give a new, larger value: 5050 more. The total is 7676.

Common mistake

Two classic traps. First, ⌊−x⌋≠−⌊x⌋\lfloor -x \rfloor \ne -\lfloor x \rfloor unless xx is an integer: ⌊−5.4⌋=−6\lfloor -5.4 \rfloor = -6. Second, after naming n=⌊x⌋n = \lfloor x \rfloor and solving, you must check n≤x<n+1n \le x \lt n + 1. Most candidate values of nn fail that check.

Practice

Practice 1

What is ⌊2026⌋+⌊20263⌋\left\lfloor \sqrt{2026} \right\rfloor + \left\lfloor \sqrt[3]{2026} \right\rfloor?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 2

What is the positive real number xx with x⌊x⌋=50x \lfloor x \rfloor = 50?

Practice 3

For how many positive integers n≤100n \le 100 is ⌊n2⌋+⌊n3⌋+⌊n6⌋=n\left\lfloor \dfrac{n}{2} \right\rfloor + \left\lfloor \dfrac{n}{3} \right\rfloor + \left\lfloor \dfrac{n}{6} \right\rfloor = n?

Practice 4

Find ∑k=1100⌊k3⌋\displaystyle\sum_{k=1}^{100} \left\lfloor \frac{k}{3} \right\rfloor.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 5

What is ∑k=140⌊13k41⌋\displaystyle\sum_{k=1}^{40} \left\lfloor \frac{13k}{41} \right\rfloor?

Practice 6

For how many positive integers n≤100n \le 100 is ⌊n⌋\lfloor \sqrt{n} \rfloor a divisor of nn?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 7

How many distinct numbers are in the list

⌊12200⌋,⌊22200⌋,⌊32200⌋,…,⌊2002200⌋?\left\lfloor \frac{1^2}{200} \right\rfloor, \left\lfloor \frac{2^2}{200} \right\rfloor, \left\lfloor \frac{3^2}{200} \right\rfloor, \dots, \left\lfloor \frac{200^2}{200} \right\rfloor?

Practice 8

Find ∑k=11000⌊log⁡2k⌋\displaystyle\sum_{k=1}^{1000} \lfloor \log_2 k \rfloor.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Real contest practice

  • 2020 AMC 10A, Problem 22: when a sum of three floors of 998n,999n,1000n\dfrac{998}{n}, \dfrac{999}{n}, \dfrac{1000}{n} is a multiple of 33.
  • 2020 AMC 10B, Problem 24: an equation mixing nn and ⌊n⌋\lfloor \sqrt{n} \rfloor, solved by naming the floor.