Create mcgcd and moved all math into the header file.

mcgcd = Most Common Greatest Common Divisor