All pastes #408470 Raw Edit

zx!/(x-y)!+x

public text v1 · immutable
#408470 ·published 2007-03-24 21:21 UTC
rendered paste body
<script language="JavaScript">
function clearInput(poElement) {
	document.getElementById(poElement).value = ''; //Null Value
}
function factorial(n) {
	var result = 1;
	for (var i = 2; i <= n; i++) {
		result *= i
	}
	return result;
}

function calcFunction(pxVal, pyVal) {
		var number;
		
		//z = x! / (x - y)! + x 
		var xVal = pxVal
		var yVal = pyVal
		
		number = factorial(xVal) / (factorial(xVal - yVal)) + xVal;
		
		alert("z = " + number);
		
		document.getElementById("answer").innerHTML = "Z = " number;
}
</script>

<form id="calcForm" name="calculator" >
	  <table border="1" align="center">
        <tr>
          <td align="center">Enter X Value </td>
          <td><input name="xVal" type="text" value="X Value" onclick="clearInput(xVal)"/></td>
        </tr>
        <tr>
          <td  align="center">Enter Y Value </td>
          <td><input name="yVal" type="text" value="Y Value" onclick="clearInput(yVal)"/></td>
        </tr>
        <tr>
          <td colspan="2" align="center">
		  <input type="button" name="computeButton" value="Compute!" onclick="calcFunction(document.calcForm.xVal.value, document.calcForm.yVal.value)"></td>
        </tr>
        <tr>
          <td colspan="2"><label id="answer">Z =</label></td>
        </tr>
      </table>
	</form>