
función no me funciona correctamente
Publicado por achd (24 intervenciones) el 14/04/2015 22:39:03
Hola, no me funciona correctamente. ¿Alguna ayuda?
Gracias.
Gracias.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<html>
<head>
<title>funcion</title>
<script>
function calcul() {
var res = document.getElementById("resultat");
var i = 1
var f = x
while (i < n) {
f = (f + x / f) / 2;
i = i + 1;
}
n = parseInt(prompt('?','Numero?'));
x = parseFloat(prompt('?','Numero?'));
res.innerHTML = "resultat: ";
}
</script>
</head>
<body>
<h3>funcion:</h3>
<form action="funcion()">
<label>n: </label>
<input type="text" id="n" placeholder="1"><br>
<label>x: </label>
<input type="text" id="x" placeholder="2"><br>
<button type="button" onclick="calcul()">calcul</button>
</form>
<p id="resultat"></p>
</body>
</html>
Valora esta pregunta


0