
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function get(v) {
var a = 1;
var b = a * a - v;
for(var i = 0; i < 10; i++) {
a = a - b / (2 * a);
b = a * a - v;
}
document.getElementById("input").value = a;
}
</script>
</head>
<body>
<input type="text" id="input" /><input type="button" value="计算" onclick="get(document.getElementById('input').value)" />
</body>
</html>