Find a function $f:\Bbb R \to \Bbb R$ which is discontinuous at $1,\frac 12,\frac 13, ... $ but is continuous at every other point 
(a) Find a function $f:\Bbb R \to \Bbb R$ which is discontinuous at $1,\frac 12,\frac 13, ... $ but is continuous at every other point.
(b) Find a function $f:\Bbb R \to \Bbb R$ which is discontinuous at $1,\frac 12,\frac 13, ... $and $0$ but is continuous at every other point.

 A: Hint: Try the functions $$f(x)=\begin{cases}x^2&:x=1/n,n\in\Bbb N\\ 0&:o.w.\end{cases}\quad\text{and}\quad g(x)=\begin{cases}1&:x=1/n,n\in\Bbb N\\ 0&:o.w.\end{cases}$$for $(a)$ and $(b)$ respectively.
A: I am personally fond of $$f(x)=\left\lfloor \frac 1 x\right\rfloor^{-1}$$
for $0< x\leq 1$ and zero elsewhere.
This is discontinuous at every $n^{-1}$ but continuous at zero. 
To make it disccontinuous at zero, just ask that $f(0)=1$, and you're done. Here's "full" plot of the function over $[-1,1]$. Note, however, it is undefined at $x=0$.


ADD There is a very nice way of constructing, given a sequence $\{x_n\}$ of real numbers, a function which is continuous everywhere except the elements of $\{x_n\}$. Let $\{c_n\}$ by any nonnegative summable sequence, and let $$s(x)=\sum_{x_n<x} c_n$$
What we do is sum through the indices that satisfy the said inequality. Because of absolute convergence, order is irrelevant. The function is monotone increasing because the terms are nonnegative, and $s$ is discontinuous at each $x_n$ because $$s(x_n^+)-s(x_n^-)=c_n$$
However, it is continuous at any other $x$: see xzyzyz's proof with the particular case $c_n=n^{-2}$. In fact, this function is lower continous, in the sense $f(x^-)=f(x)$ for any value of $x$. If we had used $x_n\leq x$, it would be upper continuous, but still discontinuous at the $x_n$.
To see the function has the said jumps, note that for $h>0$, we have $$\begin{align}\lim_{h\to 0^+} s(x_k+h)-s(x_k-h)&=\lim_{h\to 0^+}\sum_{x_n<x_k+h} c_n-\sum_{x_n<x_k-h}c_n\\&=\lim_{h\to 0^+}\sum_{x_k-h\leq x_n<x_k+h} c_n\end{align}$$
and we can take $\delta$ so small that whenever $0<h<\delta$, for any given $x_m\neq x_k$, $x_m\notin [x_k-\delta,x_k+\delta)$, so the only term that will remain will be $c_k$, as desired.
A: Let $\{a_n\}_{n \in \mathbb{N}}$ be any sequence of real numbers. The function $f(x) = \sum_{a_n \in (-\infty, x]} \frac{1}{n^2}$ is continuous everywhere apart from $a_n$. 
This definition is a bit tricky, so let me explain the notation. Pick $x \in \mathbb{R}$. Let $S_x = \{n \in \mathbb{N}: a_n \in (-\infty, x])$. Then $f(x) = \sum_{n \in S_x} \frac{1}{n^2}$.
Let $x = a_k$ for some $k$. As $f$ is obviously increasing, it's easy to see that for $y < x$, $f(x) - f(y) \geq \frac{1}{k^2}$, so $f$ is not continuous at $x$.
If $x$ is not element of sequence $\{a_n\}$, in the definition of $f(x)$ we actually take sum over $a_n \in (-\infty, x)$ instead of $a_n \in (-\infty, x]$, so for $y < x$, we have $f(x) - f(y) = \sum_{a_n \in (y, x)} \frac{1}{n^2}$. Pick any $\epsilon > 0$. Since $\sum \frac{1}{n^2}$ is convergent, pick $N > 0$ large enough so that $\sum_{n > N} \frac{1}{n^2} < \epsilon$. Next, pick $z < x$ so that that for $n \leq N$, $a_n \not \in (z, x)$. Thus for every $y \in (z, x)$, $|f(x) - f(y)| = \sum_{a_n \in (y, x)} \frac{1}{n^2} \leq \sum_{n > N} \frac{1}{n^2} < \epsilon$.
Similarly, one can show that $f$ is continuous on the right at every $x \in \mathbb{R}$ (even for $x \in \{a_n\}$). Together, this implies that $f$ is discontinuous at $\{a_n\}$ and continuous everywhere else.
A: I think the function
$$f(x)=\begin{cases}0&,\;\;x\neq\frac{1}{n}\\{}\\1&,\;\;x=\frac{1}{n}\end{cases}\;\;,\;\;\;n\in\Bbb N$$
does the trick for (b).
As for (a):
$$g(x)=\begin{cases}1&,\;\;x\neq\frac{1}{n}\\{}\\\frac{n-1}{n}&,\;\;x=\frac{1}{n}\end{cases}\;\;,\;\;\;n\in\Bbb N$$
