Menu
[B]hey guys, i have a problem while writing factorial calculations in java script.. the calculation im looking to answer is :
z = x! / (x-y)!
the following is my code so far:
<html>
function factorial(n) {
if ((n == 0) || (n == 1))
return 1
else {
var result = (n * factorial(n-1) );
return result
}
}
<script language = “javascript”>
<!–
var x = 0;
var y = 0;
var z = 0;
x = window.prompt(“Enter first number..”);
x = parseInt(x);
y = window.prompt(“Enter second number..”);
y = parseInt(y);
z = (factorial x / factorial (x-y));
alert(“THE ANSWER IS ” + z);
//–>
</script>
<body>
</body>
[B]any comments would be great..