HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <h1>JS Common Divisors</h1> <script> var num1 = 12; var num2 = 24; var txt = ""; min = (num1 < num2) ? num1 : num2; document.write("Common Divisors of "+num1+" and "+num2); for(i=1; i<= min; i++) { if( num1 % i == 0 && num2 % i == 0 ) txt += i +" "; } document.write("<br>" +txt); </script> </body> </html>
OUTPUT
×

Save as Private