bonjour tous le monde je galère depuis staprem midi pour trouver un exercice qu'on doit faire en javascript je vous explique en fait on doit écrire un chiffre mini et un chiffre maxi puis on appuie sur le bouton validez et on sa affiche une factorielle exemple : mini = 1 max = 5 validez (on appuie)
ça affiche :
n n!
1 1
2 2
3 6
4 24
5 120
voilà ce qu'on doit avoir est voici mon code je vous celui ou j'ai réussi a afficher un truc mai bon c'est pas terrible. Merci d'avance pour votre
voici le code :
<!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>
<title>Tableau des factorielles</title>
<script>
var facto ;
var mini;
var max;
var normal;
function valider()
{
mini = TextMini.value;
max = TextMax.value;
affichage = "<tr>" + "</tr>";
for( i = mini; i <= max; i++)
{
facto = calcul(mini);
normal = mini;
nbr2.innerHTML = facto;
nbr1.innerHTML = normal;
}
}
function calcul(a)
{
var j; k=0;
while(j<a)
{
k += j;
j++;
}
return k;
}
</script>
</head>
<body>
<h1>Tableau des factorielles</h1>
<p>
Mini : <input type="text" id="TextMini" />
Max : <input type="text" id="TextMax" />
<input type="button" value="Valider" onclick="javascript: valider();" />
</p>
<table id="ligne" border="1">
<tr id="ice">
<td id="nbr1"> </td> <td id="nbr2"> </td>
</tr>
</table>
</body>
</html>