easy way to do GCD problem