I assume that $G$ is a finite group (due to the tag "finite-groups" and the quote "$|G|=n$"). Note (for example, from here) that
$$|HK|\,|H\cap K|=|H|\,|K|\,.$$
That is,
$$\frac{|HK|}{|H|}=\frac{|K|}{|H\cap K|}=[K:H\cap K]\in\mathbb{Z}\,.$$
Similarly,
$$\frac{|HK|}{|K|}=\frac{|H|}{|H\cap K|}=[H:H\cap K]\in\mathbb{Z}\,.$$
That is, $|H|$ and $|K|$ both divides $|HK|$. This mean $\text{lcm}\big(|H|,|K|\big)$ divides $|HK|$, or
$$|HK|\geq \text{lcm}\big(|H|,|K|\big)\,.$$
Consequently,
$$\frac{|G|}{|HK|}\leq \frac{|G|}{\text{lcm}\big(|H|,|K|\big)}=\gcd\left(\frac{|G|}{|H|},\frac{|G|}{|K|}\right)\,.$$
From the given condition
$$\gcd\left(\frac{|G|}{|H|},\frac{|G|}{|K|}\right)=\gcd\big([G:H],[G:K]\big)=1\,,$$
we conclude that
$$\frac{|G|}{|HK|}\leq 1\text{ or }|G|\leq |HK|\,.$$
Since $HK\subseteq G$ and $G$ is a finite set, we deduce that $G=HK$.
P.S. We indeed have the following proposition. See a comment by xsnl below for a sketch of a proof.
Proposition. Let $H$ and $K$ be subgroups of an arbitrary (finite or infinite) group $G$ such that $[G:H]$ and $[G:K]$ are finite. Suppose further that $\gcd\big([G:H],[G:K]\big)=1$. Then, $G=HK$.