Last active
December 25, 2015 02:29
-
-
Save BlaShadow/6902551 to your computer and use it in GitHub Desktop.
return a mcd from a list of numbers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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