Cycymomo
7/19/2013 - 9:43 AM

140bytes - Récupérer le pgcd d'un nombre variable de nombres (gcd in english) http://www.developpez.net/forums/d1362763/webmasters-develo

140bytes - Récupérer le pgcd d'un nombre variable de nombres (gcd in english)

http://www.developpez.net/forums/d1362763/webmasters-developpement-web/javascript/ludique-defis-code-en-tweet/

console.log( pgcd(27,36) === 9 );
console.log( pgcd(128,8,32) === 8 );
console.log( pgcd(7,14,7,35,707) === 7 );
console.log( pgcd(13,17) === 1 );
console.log( pgcd(7,7) === 7 );
// 140bytes - http://www.developpez.net/forums/d1362763/webmasters-developpement-web/javascript/ludique-defis-code-en-tweet/
/* by @Barsy at developpez.com */
function pgcd2(){
a=arguments;r=a[i=0];for(;n=a[i++];)while(b=n%r)r=b;return r
}
// 140bytes - http://www.developpez.net/forums/d1362763/webmasters-developpement-web/javascript/ludique-defis-code-en-tweet/
function pgcd(){
x=function(a,b){return!b?a:x(b,a%b)};return[].reduce.call(arguments,function(a,b){return x(a,b)})
}