Return to Snippet

Revision: 6838
at June 18, 2008 12:40 by rwczippy


Initial Code
function gcm(a, b) { return ( b == 0 )?(a):( gcm(b, a % b) ); }function lcm(a, b) { return ( a / gcm(a,b) ) * b; }function lcm_nums(ar) {
if (ar.length > 1) {
ar.push( lcm( ar.shift() , ar.shift() ) );
return lcm_nums( ar );
} else {
return ar[0];
}
}

Initial URL
http://www.ideashower.com/our_solutions/leastgreatest-common-mulitple-lcmgcm-in-php-and-javascript/

Initial Description

                                

Initial Title
LCM/GCM Javascript

Initial Tags
javascript

Initial Language
JavaScript