Или так:
function NOD ( /* arguments */ ) {
return Array.prototype.reduce.call( arguments, function ( x, y ) {
while (1) {
if (!(x %= y))
return y;
if (!(y %= x))
return x;
}
});
}
alert([
NOD( 10, 15 ),
NOD( 111, 555, 407 ),
NOD( 100, 200, 300, 400, 2225, 175, 19873625 ),
NOD( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 )
].join( '\n' ));