<script
language="javascript"
type="text/javascript">
function
getGCD()
{
var
w,
x,
y;
x
=
document.lcm_gcd.a.value;
y
=
document.lcm_gcd.b.value;
while
(y
!=
0)
{
w
=
x
%
y;
x
=
y;
y
=
w;
}
return
x;
}
function
getLCM()
{
var
gcd =
getGCD();
var
lcm =
(document.lcm_gcd.a.value
*
document.lcm_gcd.b.value)
/
gcd;
document.lcm_gcd.lcmA.value
=
lcm;
document.lcm_gcd.gcdA.value
=
gcd;
}
</script>
<form
name=lcm_gcd>
<table
border=0>
<tr>
<td
width=200>
First Value
<br>
<input
type=text
name=a>
</td>
<td
width=200>
Second Value
<br>
<input
type=text
name=b>
</td>
</tr>
<tr>
<td
colspan=2
align=center>
<br>
<input
type=button
value=Solve
onClick="getLCM()">
<br>
</td>
</tr>
<tr>
<td>
Least Common Multiple
<br>
<input
type=text
name=lcmA>
</td>
<td>
Greatest Common Divisor
<br>
<input
type=text
name=gcdA>
</td>
</tr>
</table>
</form>