Large input solution with long long numbers and euclid's algo