A row of Pascal's triangle · Uma linha do triângulo 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.
Uma linha do triângulo de Pascal
Cada número no triângulo de Pascal é a soma dos dois números logo acima dele, e toda linha começa e termina com 1.
Construa as linhas uma de cada vez. Uma nova linha começa com 1, depois adiciona cada par vizinho da linha anterior, row[i] + row[i + 1], e termina com 1. Após n voltas, row é a resposta. Na China, o mesmo triângulo é nomeado em homenagem a Yang Hui, que o descreveu em 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]. · Escreva pascal_row(n) que retorne a linha n do triângulo de Pascal, contando a linha superior [1] como linha 0. A linha 4 é [1, 4, 6, 4, 1].
Click Run to see the output here. · Clique em Executar para ver a saída aqui.