|
Voici un exemple d'une classe permettant d'afficher un triangle Pascal que j'ai développer pour un exercice à l'école:
<script type="text/javascript" language="javascript">
// Triangle de nombre de Pascal
for ( i = 0; i < 10; i++) {
for ( j =0; j <= i; j++) {
document.write(" "+j*i);
}
document.write("<BR>");
}
// Dessin Triangle
for ( i = 0; i < 13; i++) {
for ( j = 0; j <= 13-i; j++) document.write(" ");
document.write("< ");
for ( j = 0; j <= i+i; j++) document.write("x ");
document.write("*<BR>");
}
</script>
|
on obtiendra le résultat suivant:
0
0 1
0 2 4
0 3 6 9
0 4 8 12 16
0 5 10 15 20 25
0 6 12 18 24 30 36
0 7 14 21 28 35 42 49
0 8 16 24 32 40 48 56 64
0 9 18 27 36 45 54 63 72 81
< x *
< x x x *
< x x x x x *
< x x x x x x x *
< x x x x x x x x x *
< x x x x x x x x x x x *
< x x x x x x x x x x x x x *
< x x x x x x x x x x x x x x x *
< x x x x x x x x x x x x x x x x x *
< x x x x x x x x x x x x x x x x x x x *
< x x x x x x x x x x x x x x x x x x x x x *
< x x x x x x x x x x x x x x x x x x x x x x x *
< x x x x x x x x x x x x x x x x x x x x x x x x x *
|
Voir également
Science - Mathématique
|
|
| Dernière mise à jour: Vendredi, le 10 mars 2006 |