added GCD solution