Numbers $a$ such that if $a \mid b^2$ then $a \mid b$

They are the square-free integers.

In other words those of the form $p_1p_2 \dots p_k$ where $p_i$ is a distinct prime for each $i$.

Clearly if $n$ is squarefree and $n\mid a^2$ then every prime of $n$ divides $a$ and therefore, $n$ divides $a$ (since $n$ is the least common multiple of its prime divisors).

Suppose a number is not square free, write it as $n=p^{a}k$ with $a>1$ and $p \nmid k$, let $x=\lceil a/2 \rceil$. Then $n\mid p^{2x}k^2$ and $n\nmid p^xk$.


Suppose $p^m\mid a$ and $p^{m+1}\nmid a$, where $p$ is prime and $m>0$. Then $a=p^mc$, so $a\mid p^{m'}c^2$, where $m'=m$ if $m$ is even or $m'=m+1$ if $m$ is odd. Then $a\mid p^{m'/2}c$ forces $p^m\mid p^{m'/2}c$ and therefore $m\le m'/2$. This can only happen if $m=1$: $$ 2m\le m+1 $$ means $m\le 1$.

So $a=1$ or $a$ must be a product of distinct primes. Now show the converse.