The interested reader is referred to "Mathematics and Music" by David Wright, published by the American Mathematical Society. The realization that the circle of fifths is really there because 5 and 7 (aka -5) are co-prime to 12 was worth the entire thing! Together with 1 and 11 (aka -1) they generate the group Z_{n} for n = 12...
That explains why the circle of fifths is a circle that goes through all keys, but the really interesting thing about the circle of fifths is that a fifth sounds relatively close to the key next to it, and it doesn't really explain that, I guess.
Any key a fifth away only changes one note - if you go from C Major (CDEFGABC) to G Major (GABCDEF#G) then only the F# has changed, and as a result there are chords which are common between the two keys - any chord without an F in it in C will be common to G as well. Works the other way if you go 'down' a fifth (to F), but has a flat instead. (Bb)
More specifically, going up a fifth augments the fourth by a semitone to become the seventh and going down a fifth diminishes the seventh by a semitone to become the fourth. In your example, F the fourth became F# the seventh and B the seventh became Bb the fourth. A fifth away _IS_ a semitone away.
Defining the following eight functions:
SEMITONE = +1 mod 12; ANTI_SEMITONE = SEVENTH;
FOURTH = +5 mod 12; ANTI_FOURTH = FIFTH;
FIFTH = +7 mod 12; ANTI_FIFTH = FOURTH;
SEVENTH = +11 mod 12; ANTI_SEVENTH = SEMITONE;