Some good answers on here already. I just want to mention the Möbius function $\mu(n) = \delta_{\omega(n)}^{\Omega(n)} (-1)^{\omega(n)}$. Basically this says that if $n$ has any repeated prime factors, then $\mu(n) = 0$, otherwise $\mu(n) = -1$ or $1$ depending on a fact not relevant for this particular application. (Note that $\mu(1) = 1$, this is a consequence of $1$'s non-primality, not a reason for it.) Some computer algebra systems implement this as MoebiusMu
or moebiusmu
.
Your question then becomes one of finding $n$ such that $\mu(k) = 0$ for $n \leq k \leq n + 4$. Or $n$ such that $$\sum_{k = n}^{n + 4} |\mu(k)| = 0.$$ There are infinitely many such runs and a few different ways of finding them.
If you want to find the first $n$, then I suppose you have to test numbers one by one. But if you're more interested in the factorization of $n$ having certain properties, then you can use the Chinese remainder theorem. Keep in mind that since $4 = 2^2$, if you choose to make $n$ a multiple of $4$, then you automatically get $n + 4$ non-squarefree without having to work for it. But this means that $n + 2$ must be divisible by an odd square. You also need this for $n + 1$ and $n + 3$, of course. One possible system of congruences you can use is:
- $n \equiv 0 \pmod 4$
- $n \equiv 8 \pmod 9$
- $n \equiv 23 \pmod{25}$
- $n \equiv 46 \pmod {49}$
One solution is $n = 29348$. This gives us:
- $29348 = 4 \times 7337$
- $29349 = 9 \times 3261$
- $29350 = 25 \times 1174$
- $29351 = 49 \times 599$
- $29352 = 4 \times 7338$
If for whatever reason you only want one multiple of $4$ in the run, that can be found, too. Try $n = 4225074$ for instance.