This answer attempts to give a dumbed down version of the answer on Math.SE.
Say there are two logicians, A and B; and two colors, $0$ and $1$.
Mr. A looks at his friend and guesses that they are wearing the same hat. Mr. B knows that Mr. A is predictable and will guess that they are the same, so he will guess they are different. Without knowing what either person saw we can see that all answers are covered.
Them being the same is the same as saying that the sum of their colors is equal to $0 \bmod 2$ as $0+0=0$ and $1+1=2=0 \bmod 2$. Them being different is, similarly, $1 \bmod 2$.
The easiest solution, therefore, is for every person to guess that the sum of all the colors' numbers is equal to their seat number $S$ modulo the number of people.
The way to see this is to note that the equation for 5 logicians and 5 colors is: $a+b+c+d+e=S \bmod 5$ where each variable refers to the color number of the player with the same name.
For Mr. A, he knows what $b$, $c$, $d$, and $e$ add up to be and only doesn't know $a$ so he guesses $S=0 \bmod 5$ which means that $a=0-b-c-d-e \mod 5$.
Mr. B, he knows what Mr. A will guess, so he guesses $S=1 \bmod 5$, so $b=1-a-c-d-e \mod 5$.
By the time we get through 5 guessers we will guess:
Mr. A: $S=0 \bmod 5$
Mr. B: $S=1 \bmod 5$
Mr. C: $S=2 \bmod 5$
Mr. D: $S=3 \bmod 5$
Mr. E: $S=4 \bmod 5$
which is of course every possibility.
As you make up colors (one person in a circle with only black and white hats can yell purple
'purple'), this means any number of players can guess at least one of their hats correctly for any number of colors less than or equal to the number of players.