Version compl�te: jsB@nk » Calcul » Math » PGCD/LCM Calculatrice
URL: https://www.javascriptbank.com/gcd-lcm-calculator.html
Cet Calculateur de code peut déterminer rapidement le plus grand facteur commun et les moins de multiplication entre deux ou trois numéros.
Version compl�te: jsB@nk » Calcul » Math » PGCD/LCM Calculatrice
URL: https://www.javascriptbank.com/gcd-lcm-calculator.html
<script type="text/javascript"><!-- Original: Seamus Yim --><!-- Beginfunction go(input1,input2,input3){ if (document.form1.text3.value!=""){ document.form1.answer.value=hcf(hcf(input1,input2),input3); document.form1.answer2.value=lcm(lcm(input1,input2),input3); } else { document.form1.answer.value=hcf(input1,input2); document.form1.answer2.value=lcm(input1,input2); }}function hcf(text1,text2){ var gcd=1; if (text1>text2) {text1=text1+text2; text2=text1-text2; text1=text1-text2;} if ((text2==(Math.round(text2/text1))*text1)) {gcd=text1}else { for (var i = Math.round(text1/2) ; i > 1; i=i-1) { if ((text1==(Math.round(text1/i))*i)) if ((text2==(Math.round(text2/i))*i)) {gcd=i; i=-1;} } } return gcd;}function lcm(t1,t2){ var cm=1; var f=hcf(t1,t2); cm=t1*t2/f; return cm;}// End --></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name="form1">First Number: <input type="text" name="text1" size="3"> Second Number: <input type="text" name="text2" size="3"><br> Third Number (<em>not required</em>): <input type="text" name="text3" size="3"><br><br><input type="button" value="Find GCF and LCM" onclick="go(eval(document.form1.text1.value),eval(document.form1.text2.value),eval(document.form1.text3.value))"><br><br>Greatest Common Factor (GCF): <input type="text" name="answer" size="3" readonly><br>Least Common Multiplier (LCM): <input type="text" name="answer2" size="3" readonly></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->