gcd without recursion