»
EnglishFrenchVietnamese

Print - Solving factorials - JavaScriptBank.com

Full version: jsB@nk » » Solving factorials
URL: https://www.javascriptbank.com/solving-factorials.html

Solving factorials © JavaScriptBank.comThis JavaScript calculates factory of number.

Full version: jsB@nk » » Solving factorials
URL: https://www.javascriptbank.com/solving-factorials.html



JavaScript
<script language="javascript">//solving factorialsvar factored = 1;function factorial(form) {var number = form.factor.value;var n = number;for (i = n; i>0 ; i--){if (n>170){form.result.value="Hey! that is too big for my pea brain";}else{if (i==n){factored= i;}else{factored = factored*(i);}form.result.value=factored;}}return factored;} </script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form method="post"><input type="text" size="4" maxlength="4" name="factor"><input type="button" onclick="factorial(this.form)" value="factorate"><input type="text" size="40" maxlength="40" name="result"></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->