Why is $\lfloor n/3 \rfloor + \lceil 2n/3\rceil = n?$

1.6k Views Asked by At

Why is $\lfloor n/3 \rfloor + \lceil 2n/3\rceil = n?$

It feels like I'm just doing basic fraction addition since

$$\frac{n}{3}+\frac{2n}{3}=n$$

So then how does ceil and floor play a role in addition?

5

There are 5 best solutions below

0
On BEST ANSWER

Let $n=3k + r$, where $r\in \{0,1,2\}$. Then $\lfloor\frac{n}{3}\rfloor = k$. Also, $\lceil\frac{2n}{3}\rceil=\lceil\frac{6k + 2r}{3}\rceil=2k+\lceil \frac{2r}{3}\rceil$. Therefore, $$\left\lfloor\frac{n}{3}\right\rfloor + \left\lceil\frac{2n}{3}\right\rceil = 3k + \left\lceil\frac{2r}{3}\right\rceil.$$ The claim immediately follows by noting that $\lceil\frac{2r}{3}\rceil = r$ for $r \in \{0,1,2\}$.

1
On

Hint: do the actual computation (with floor and ceiling) for various sample values of $n$ - say $1$ through $6$.

You'd better assume $n$ is an integer. Can you see why?

0
On

Note that the following identities hold for all integer $n$, real $x$:

  • $\lceil n+x \rceil = n + \lceil x \rceil$ (and $\lfloor n+x \rfloor = n + \lfloor x \rfloor$, but we don't need that)
  • $\lceil -x \rceil = -\lfloor x \rfloor$

Thus, if $n$ is an integer, we have: $$\lceil 2n/3 \rceil=\lceil n+(-n/3)\rceil=n+\lceil -n/3\rceil=n-\lfloor n/3\rfloor$$

0
On

Note that both $\frac n3-\left\lfloor\frac n3\right\rfloor$ and $\left\lceil\frac{2n}3\right\rceil-\frac{2n}3$ have a period of $3$. Subtracting we get that $$ \left\lceil\frac{2n}3\right\rceil+\left\lfloor\frac n3\right\rfloor-n\tag{1} $$ has a period of $3$. Thus, we only need to check $n=0,1,2$ to verify $$ \left\lceil\frac{2n}3\right\rceil+\left\lfloor\frac n3\right\rfloor=n\tag{2} $$ for all $n$.

0
On

For ease of typing let $f(z)=floor(z)$ and $c(z)=ceil(z).$

We have $n=3m+x$ where $m\in \mathbb Z$ and $x\in \{0,1,2\}.$

(i). If $x=0$ then $f(n/3)+c(2n/3)=f(m)+c(2m)=m+2m=3m=3m+x=n.$

(ii). If $x=1$ then $f(n/3)+f(2n/3)=f(m+1/3)+f(2m+1/3)=m+(2m+1)=3m+1=3m+x=n.$

(iii). If $x=2$ then $$f(n/3)+c(2x/3)=f(m+2/3)+c(2m+4/3=f(m+2/3)+c((2m+1)+1/3)=$$ $$=m+(2m+2)=3m+2=3m+x=n.$$