Multiple variables calculus: condition for $f$ to be continuous using curves 
Prove $f:\mathbb{R}^n\to\mathbb{R}$ is continuous iff for every curve, $\gamma:[a,b]\to\mathbb{R}^n: f\circ \gamma :\mathbb{R}\to\mathbb{R}$ is continuous. 

$(\Rightarrow)$ is trivial.
$(\Leftarrow)$: Intuitively, $f$ is continuous at every subset on it's domain, so all in all $f$ is continuous. 
How to formalize this? What should I rely on?
Thanks.
 A: Let $(p_i)_{i\ge 1}$ a sequence of points in $\mathbb{R}^n$ converging to $p$.  Consider the following function
$\gamma\colon [0,1] \to \mathbb{R}^n$: $\gamma(\frac{1}{i}) = p_i$, $\gamma$ is linear on each interval $[\frac{1}{i+1}, \frac{1}{i}]$, and $\gamma(0)=p$.  One checks easily that $\gamma$ is continuous. 
Assume that $f \circ \gamma$ is also continuous. Then $\lim_{t\to 0} f(\gamma(t)) = f(\gamma(0))$ and therefore
$\lim_{ i \to \infty} f(\gamma(\frac{1}{i})) = f(\gamma(0))$ or $\lim_{ i \to \infty} f(p_i) = f(p)$. 
It's easy from here. 
This works more generally if instead of $\mathbb{R}^n$ we have a normed vector space. 
A: Let's try this.  Suppose $f$ is not continuous at $x=a$. Then there is an $\epsilon>0$ such that for every $n\in\Bbb Z_+$ there is a point $x_n$ such $|x_n-a|< \frac{1}{n} $ and $|f(x_n)-f(a)|\ge \epsilon$. Now, let $\gamma_n$ be a parametrized line from $x_{n}$ to $x_{n+1}$.
Now, we can "string" the $\gamma_n$ together to create a path $\gamma$ such that $f\circ\gamma$ that is not continuous.
A: This isn't the most elementary approach, but it's fun. Notice that the existence of the Hilbert curve means we can find an surjective continuous function $f:[-1,1]\rightarrow [-1,1]^n$. Let us, for convenience, assume that $f(0)=0$ and $\gamma(0)=0$ and prove continuity of $f$ at $0$. Then, using a construction similar to Hilbert's, choose some $\gamma$ which has that the image
$$\gamma \left(\left[\frac{1}{4^n},\frac{2}{4^n}\right]\right)=\left[-\frac{1}{2^n},\frac{1}{2^n}\right]^n$$
and that the intervening intervals of the form $\left[\frac{2}{4^n},\frac{4}{4^n}\right]$ are interpolated arbitrarily. Now, if $f\circ \gamma$ is continuous then we know that, for any $\varepsilon>0$, there is an $\delta>0$ such that if $f(\gamma(t))<\varepsilon$ for all $|t|<\delta$. However, the image $\gamma((-\delta,\delta))$ always contains a neighborhood of $0$ due to the construction of $\gamma$. Therefore, we can say that $f(x)<\varepsilon$ for all $x$ in a neighborhood of $0$, ergo $f$ is continuous there.
