A row of Pascal's triangle
このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
これはまだ完了していないレッスンの先にある内容です。まずはそのレッスンを済ませてください:
Python Basics · Functions →
パスカル三角形の一行
Every number in Pascal's triangle is the sum of the two numbers just above it, and every row starts and ends with 1.
行を1つずつ作成します。新しい行は 1 で始まり、前の行の隣り合うペアを順に row[i] + row[i + 1] として加え、 1 で終わります。 n 回繰り返すと、 row が答えになります。中国では、この三角形は楊輝によって 1261 で記述されたことにちなんで「楊輝三角」と呼ばれています。
難易度 5/5 · 400 コイン + 今日初回達成時の小ボーナス
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].
実行ボタンをクリックして出力を確認してください。