Accepted solution.
Custom 'greatest common devisor' implementation.