<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> </body> </html> <script> /*var a=prompt("请输入一个整数") if(a==null) { } else { var b=isNaN(a) ; if (b==false) { var c=parseInt(a); var sum=0; for (var i=0;i<c;i++) { sum+=i; } document.write(sum) } else { alert(请输入整数) } }*/ var a=prompt("请输入一个整数") if (a==null) { } else { var b=isNaN(a); if (b==false) { var sum =0; var jie =1; var c=parseInt(a); for(var i=1; i<=c;i++ ) { jie*=i; sum+=jie; } document.write(sum) } else { alert("请输入整数") } } </script>
时间: 2024-10-07 05:16:48