Real Analysis Limit of a Sequence Question

I'm working on this question (from an introductory Real Analysis textbook):

Define a sequence $(a_n)^{\infty}_{n=1}$ such that $\lim_{n \to \infty} a_{n^2}$ exists but $\lim_{n \to \infty} a_n$ does not exist.

I've come up with a sequence for which this holds.

Define

$$a_n = \left\{\begin{matrix} 0 \; \; \; \text{if} \; \; \sqrt{n} \in \mathbb{I}\\ 1 \; \; \; \text{if} \; \; \sqrt{n} \notin \mathbb{I} \end{matrix}\right.$$

where $n \geq 1$ and $n \in \mathbb{I}$. This sequence does not converge, as $(a_n)$ flips between $0$ and $1$, depending on whether or not $\sqrt{n}$ is an integer. However, for $(a_{n^2})$, we have,

$$a_{n^2} = \left\{\begin{matrix} 0 \; \; \; \text{if} \; \; \sqrt{n^2} \in \mathbb{I}\\ 1 \; \; \; \text{if} \; \; \sqrt{n^2} \notin \mathbb{I} \end{matrix}\right.$$

$$= \left\{\begin{matrix} 0 \; \; \; \text{if} \; \; n \in \mathbb{I}\\ 1 \; \; \; \text{if} \; \; n \notin \mathbb{I} \end{matrix}\right.$$

which of course is simply a sequence of zeros and as such "converges" to zero. Have I taken the right approach? Or should I be using the limit definition to define a more general sequence for which the given conditions hold. Thanks for any input.

-
Looks good to me. The question asks for a sequence and you've found one. If you want to improve your answer, you can rigorously show that $a_n$ diverges. – Ayman Hourieh Feb 20 '13 at 22:06
Too many symbols. Before typing all those symbols, you had an informal idea and knew that it worked: $f(k)=1$ if $k$ is a perfect square, and $fk)=0$ otherwise. Say it that way. – André Nicolas Feb 20 '13 at 22:10

Yeah it works but you could express it simplier with $$a_n = \left\{ \begin{array}{rl} 1 & \exists k \in \mathbb{N} : k^2=n \\ 0 & \text{else} \end{array}\right.$$
Your answer is correct and convincing: you needed only to "find" such a sequence, and indeed you did. I'd simply add that to make the argument fully convincing (or, perhaps more rigorous, as it seems pretty convincing to me), it might be a good idea to demonstrate that it is, indeed, an example of such a sequence (i.e., explicitly prove that indeed, $\;\large a_{n^2}\;$ converges to 0).