Finding number given least common multiple with $24$

Is there any easier or algorithmic method to solve this problem?

There are two numbers, $n$ and $6$. The least common multiple of $n$ and $6$ is $24$. Find $n$.

The way I do this is by expressing $6$ and $24$ into their prime factorisations.

$6=2\cdot3$ and $24=2^3\cdot3$. By simply observing and do simple reasoning, we can see that $n$ can be either $8$ or $24$. Right?

I know that if we are given its $\operatorname{gcd}$, then we can use $n\times6=\operatorname{lcm}(n,6)\cdot \operatorname{gcd}(n,6)$. But we are not given its $\operatorname{gcd}$ here.

If we try to explain this to a student who just learned about $\operatorname{lcm}$, how can we explain it in a simplest manner? Thanks.

Hint:

$\gcd(n,6)=1,2,3 \text{ or } 6$ since it must be a divisor of $6$.

Try each in turn to see which give answers which work with the original question and which do not.

So, $n$ must divide $\displaystyle24\implies n$ is of the form $2^a3^b$ where integers $0\le a\le3,0\le b\le1$

So, $\operatorname{lcm}\displaystyle(n,6)=2^{\text{max}(a,1)}\cdot3^{\text{max}(b,1)}=24=2^3\cdot3^1$

So, $b$ can be $0,1$

Hope you can take it home from here?

first of all express 24 in prime factorization.now we know that lcm of any two given numbers is the product of highest powers of prime factors. 24=2^3.3 in it highest power of 2 is 3.If we express 6 in prime factorization highest power of 2 is 1 (6=2.3) hence n must contain highest power of 2 i.e 2^3 must be a factor of n. Highest power of 3 is 1 and 6 has 3 as a factor so n may or may not contain 3. Hence n may be 2^3=8 or may be 2^3.3=24.