A row of Pascal's triangle · Une ligne du triangle de Pascal
A row of Pascal's triangle
Every number in Pascal's triangle is the sum of the two numbers just above it, and every row starts and ends with 1.
Build the rows one at a time. A new row starts with 1, then adds each neighbouring pair of the previous row, row[i] + row[i + 1], and ends with 1. After n rounds, row is the answer. In China the same triangle is named after Yang Hui, who described it in 1261.
Une ligne du triangle de Pascal
Chaque nombre dans le triangle de Pascal est la somme des deux nombres situés juste au-dessus, et chaque ligne commence et finit par 1.
Construire les lignes une par une. Une nouvelle ligne commence par 1, puis ajoute chaque paire voisine de la ligne précédente, row[i] + row[i + 1], et finit par 1. Après n tours, row est la réponse. En Chine, le même triangle porte le nom de Yang Hui, qui l'a décrit en 1261.
Write pascal_row(n) that returns row n of Pascal's triangle, counting the top row [1] as row 0. Row 4 is [1, 4, 6, 4, 1]. · Écrivez pascal_row(n) qui retourne la ligne n du triangle de Pascal, en comptant la ligne supérieure [1] comme ligne 0. La ligne 4 est [1, 4, 6, 4, 1].
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.