Replaced recursive version of GCD function to iterative one.