Is there a function which has limit only given $a_1,a_2...a_n....$ infinite points. Find a function which has limit only in advanced marked points$(a_1,a_2,....a_n)$.
Here is my example.
$g(x) =
\begin{cases}
1,  &amp; \text{if}~x\in\mathbb{Q} \\
0, &amp; \text{if}~x\in\Bbb{R}\backslash \Bbb{Q}
\end{cases}$
$f(x) = (x-a_1)(x-a_2)...(x-a_n)g(x)$
But the problem I can't solve is that,is there a function which has limit only in advanced  given $a_1,a_2...a_n....$ infinite points.
An equivalent way of asking this question is whether there exists a function which is continuous only on a given sequence.
Such a function may fail to exists, for example when your sequence is dense in $\mathbb{R}$ (e.g. $\mathbb{Q}$). Because the set of continuity points must be a $G_\delta$ subset (and therefore cannot be dense and countable).
On the other hand, if your sequence has no limit points, then one can easily construct such a function by dividing $\mathbb{R}$ into intervals, each containing a single element of the sequence, and then define the function on the each interval to be continuous only on that element (for example as you suggested in your question).
Assume that there is an order preserving bijection between $a_n$ and N.
Define
$$ f(x)=\frac{1}{n}, \quad x \in[a_n, a_{n+1}).
$$
Then the function is discontinuous at every $a_n$ but has a right limit as $x \to a_n$.
If, however, you want double-sided limits then take a small $\delta$ and modify as
$f(x)=\frac{1}{n}$ for x $\in(a_n-\delta, a_{n}+\delta)$ and $f(x)=i$ inbeween (imaginary).
But in this case, you are going outside ot the real numbers.
From the perspective of the real numbers, the function is undefined between the intervals.