int gcd( int a, int b ) {
return b == 0 ? a : gcd( b, a % b );
}
int gcdOfList( int *list, int num ) {
int result = list[0];
for( int i = 1; i < num; ++i ) {
result = gcd( result, list[i] );
}
return result;
}
A blog about coding
int gcd( int a, int b ) {
return b == 0 ? a : gcd( b, a % b );
}
int gcdOfList( int *list, int num ) {
int result = list[0];
for( int i = 1; i < num; ++i ) {
result = gcd( result, list[i] );
}
return result;
}