Construct a function which is continuous in $[1,5]$ but not differentiable at $2, 3, 4$

Construct a function which is continuous in $[1,5]$ but not differentiable at $2, 3, 4$.

This question is just after the definition of differentiation and the theorem that if $f$ is finitely derivable at $c$, then $f$ is also continuous at $c$. Please help, my textbook does not have the answer.

-
Intuitively, a function is differentiable at a point if the graph of the function at that point is "smooth". –  JavaMan Oct 20 '11 at 17:54
Just make some kind of saw-tooth with peeks in 2, 3, 4. –  Jonas Teuwen Oct 20 '11 at 17:55
Intuitively, a function is continuous if you can "walk" on the graph and it is differentiable if you can see where you came from and where you are going. –  AD. Oct 25 '11 at 18:05
@AD. Intuitively, a real-valued function of one real variable is differentiable if you can "walk" on its graph without stopping. –  Amitesh Datta Oct 26 '11 at 8:59

$|x|$ is continuous, and differentiable everywhere except at 0. Can you see why?

From this we can build up the functions you need: $|x-2| + |x-3| + |x-4|$ is continuous (why?) and differentiable everywhere except at 2, 3, and 4.

-

$$\ \ \ \ \mathsf{W}\ \ \ \$$

-
OK, I confess: I always dreamt of reading/posting an answer with only one character... so I could not resist the occasion. –  Did Oct 20 '11 at 19:48
+1 for succinctness. –  aardvarkk Oct 20 '11 at 19:50
Best answer ever! –  Ｊ. Ｍ. Oct 20 '11 at 22:36
How about $f(x) = \max(\sin(n\pi x),0)$ or perhaps $g(x) = |\sin(n\pi x)|$?
You're right, I think, because we're considering only one-sided derivatives at $1$ and $5$. –  Saaqib Mahmuud Aug 16 '13 at 9:45