<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>阶乘计算器</title> </head> <body> <form> <input type="text" id='number1' /> <button type="submit" onclick='factorial()'>Submit</button> <br /> <input type="text" id='number2' /> </form> <script type="text/javascript"> function factorial(){ var num1=parseInt(document.getElementById('number1').value); var num2=document.getElementById('number2').value; if (num1<=1) { num2=1; } else{ num2=num1*arguments.callee(num1-1); } } </script> </body> </html>
qq___524
相关分类