A row of Pascal's triangle
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.
파스칼의 삼각형의 한 줄
파스칼의 삼각형의 모든 숫자는 바로 위 두 숫자의 합이며, 모든 줄은 1로 시작하고 끝납니다.
줄을 하나씩构建합니다. 새 줄은 1으로 시작하고 이전 줄의 각 이웃 쌍인 row[i] + row[i + 1]을 더하며, 1로 끝납니다. n 번의 라운드 후, row이 정답입니다. 중국에서는 이 삼각형을 1261년에 서술한 양후(Yang Hui)의 이름을 따 양후삼각형이라고 부릅니다.
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].
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.