Skip to content

Instantly share code, notes, and snippets.

@BlaShadow
Last active December 25, 2015 02:29
Show Gist options
  • Save BlaShadow/6902551 to your computer and use it in GitHub Desktop.
Save BlaShadow/6902551 to your computer and use it in GitHub Desktop.
return a mcd from a list of numbers.
function mcd()
{
var mcd = 1;
var tmpMcd = 1;
var values = [].slice.call(arguments);
values = values.sort(function(a,b){ return a - b; });
var minVal = values[0];
for(i=0;i<=minVal;i++)
{
var salir = false;
for(e=0;e<values.length;e++)
{
if( values[e] % tmpMcd != 0 )
{
salir = true;
break;
}
}
if(salir == false)
{
mcd = tmpMcd;
}
tmpMcd ++;
}
return mcd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment