Iterated Fractional Part Function Let   $f(x)=|2\{x\}-1|$ where $\{x\}$ denotes the fractional part of $x$.  The number $n$ is the smallest positive integer such that the equation $nf(xf(x))=x$ has at least $2012$ real solutions.  What is $n$? 
 A: Notice that $0\leq f\leq 1$ so we only need to worry about $x\in [0,n]$ in solving $nf(u)=x$. Also notice that $f$ vanishes only at half-integers, and hits its maximum of $1$ at the integers. 
Re-write $f$ piecewise, for any $k\in\mathbb{N}_0:$
$$f(x) = \left\{ 
  \begin{array}{l l}
    2k+1-2x & \quad \text{for}\;k\leq x<k+\frac{1}{2}\\
    2x-2k-1 & \quad \text{for}\;k+\frac{1}{2}\leq x<k+1
  \end{array} \right.$$
Consider:
$$xf(x) = \left\{ 
  \begin{array}{l l}
    2kx+x-2x^2 & \quad \text{for}\;k\leq x<k+\frac{1}{2}\\
    2x^2-2kx-x & \quad \text{for}\;k+\frac{1}{2}\leq x<k+1
  \end{array} \right.$$
Observe that $xf(x)$ decreases monotonously from $k$ to $0$ on $[k,k+\frac{1}{2}]$ and increases monotonously to $k+1$ on $[k+\frac{1}{2},k+1]$ ($k=0$ is an exception to the first statement, but it still agrees with what follows).
This implies that $xf(x)$ hits half-integers exactly $k$ times on $[k,k+\frac{1}{2}]$ and $k+1$ times on $[k+\frac{1}{2},k+1]$. In other words, $f(xf(x))$ vanishes exactly $2k+1$ times on $[k,k+1]$. 
Hence for $x\in [0,n],\;f(xf(x))$ must vanish exactly $\displaystyle\sum_0^{n-1} 2k+1=n^2$ times.
Therefore $nf(xf(x))$ will oscillate between $0$ and $n$ exactly $n^2$ times on $[0,n]$, and since for each oscillation $y=x$ will intersect $nf(xf(x))$ twice, the number of solutions to $x=nf(xf(x))$ is $2n^2$.
$$2012\leq 2n^2\Rightarrow\sqrt{1006}\leq n$$
Since $\sqrt{1006}\approx 31.71$ the smallest $n$ is $32$.
