リソース · ガイド・記事
Pascal's Triangle
パスカルの三角形が二項係数からどう作られるか、そして1行を効率よく計算する方法を説明しています。組み合わせ論のコーディング問題に出てくるパターンです。
確認日
元のサイトを開く: Pascal's Triangle (元のサイトを新しいタブで開きます)ロードマップに追加
取り組んでいるロードマップにこのリソースを追加できます。自分用の追加リソースとして表示され、ロードマップの手順は変わらず、記録した手順数にも数えられません。
出典コンテンツの言語:英語
In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. The rows of Pascal's triangle are conventionally enumerated starting with row n = 0 at the top (the 0th row). The entries in each row are numbered from the left beginning with k = 0 and are usually staggered relative to the numbers in the adjacent rows. The triangle may be constructed in the following manner: In row 0 (the topmost row), there is a unique nonzero entry 1. Each entry of each subsequent row is constructed by adding the number above and to the left with the number above and to the right, treating blank entries as 0. For example, the initial number in the first (or any other) row is 1 (the sum of 0 and 1), whereas the numbers 1 and 3 in the third row are added to produce the number 4 in the fourth row. The entry in the nth row and kth column of Pascal's triangle is denoted . For example, the unique nonzero entry in the topmost row is .
PrepKit の概要
この概要は PrepKit 編集部がソースリポジトリをもとに執筆・確認したもので、リソース本文の引用ではありません。
- 対象
- ソースにレベルの記載はありません
- 形式
- リファレンス
扱っている内容
- 作り方の規則:各要素は真上の2つの要素の和で、空白は0として扱います。
- 要素と二項係数の関係を示す公式の節。
- 三角形の要素を O(n) 時間で計算する方法:C(n, i - 1) から C(n, i) を各ステップ O(1) で求めます。
使い方
PrepKit の学習アドバイスであり、ソースの主張ではありません。
10行目を、前の行を足し合わせる方法と C(n, i - 1) の漸化式による方法の2通りで生成し、両者が一致することを確かめてください。
範囲と制約
公式は描画された画像で、ページは Wikipedia と GeeksForGeeks へのリンクに頼っています。演習はありません。
利用方法と形式
GitHub で読めます。MIT ライセンスの trekhleb/javascript-algorithms プロジェクトの英語の README です。
PrepKit が 2026/10/02 に確認しました。 リソースの出典のコミット: 85293e3e2b88
この概要の根拠
- src/algorithms/math/pascal-triangle/README.md
この項目を掲載しているページ
PrepKit ニュースレターを受け取る
任意です。PrepKit の利用には必要ありません。