These two problems appear in my textbook:

Give a function f: R to R continuous only at x = 0 and x = 1.

For this, let f(x) = x^2 if x is rational and x if x is irrational.

Then it is continuous only at x^2 = x which implies x equals 0,1.

Give a function f: R to R continous only at x1, x2,....,xn.

This one I'm not really sure what to do. Can you do something similar to the first one?

Any help would be appreciated.