Solution (source code)

= Solution

An odd composite integer $n>1$ coprime to $b$ is a <Fermat pseudoprime> to base $b$ if $b^{n-1}\equiv1\pmod n$. A <Carmichael number> is a composite integer satisfying this congruence for every integer $b$ coprime to $n$. The <Korselt criterion> says that a composite $n$ is a <Carmichael number> exactly when it is <squarefree> and $p-1$ divides $n-1$ for every <prime> divisor $p$ of $n$.