リソース · ガイド・記事
Primality Test
素数、合成数、素数判定が何に答えるかを定義するページで、isPrime 関数を書く前に用語を押さえておきたい人向けです。
確認日
元のサイトを開く: Primality Test (元のサイトを新しいタブで開きます)ロードマップに追加
取り組んでいるロードマップにこのリソースを追加できます。自分用の追加リソースとして表示され、ロードマップの手順は変わらず、記録した手順数にも数えられません。
出典コンテンツの言語:英語
A prime number (or a prime) is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1, involve 5 itself. However, 6 is composite because it is the product of two numbers (2 × 3) that are both smaller than 6. A primality test is an algorithm for determining whether an input number is prime. Among other fields of mathematics, it is used for cryptography. Unlike integer factorization, primality tests do not generally give prime factors, only stating whether the input number is prime or not. Factorization is thought to be a computationally difficult problem, whereas primality testing is comparatively easy (its running time is polynomial in the size of the input).
PrepKit の概要
この概要は PrepKit 編集部がソースリポジトリをもとに執筆・確認したもので、リソース本文の引用ではありません。
- 対象
- ソースにレベルの記載はありません
- 形式
- リファレンス
扱っている内容
- 素数と合成数の定義。5 と 6 を例にしています。
- 素数判定と素因数分解の違いと、判定は多項式時間で実行できるという注記。
使い方
PrepKit の学習アドバイスであり、ソースの主張ではありません。
試し割りによる isPrime を書き、約数を平方根まで調べれば十分な理由を声に出して説明してください。この上限はこの README ではなく、他の資料にある内容です。
範囲と制約
内容はごく薄く、判定方法の名前も、特定の手法のコード解説や計算量もなく、Wikipedia への2つのリンクに頼っています。
利用方法と形式
GitHub の trekhleb/javascript-algorithms(MIT)にある英語の README で、無料で読めます。
PrepKit が 2026/10/02 に確認しました。 リソースの出典のコミット: 85293e3e2b88
この概要の根拠
- src/algorithms/math/primality-test/README.md
この項目を掲載しているページ
PrepKit ニュースレターを受け取る
任意です。PrepKit の利用には必要ありません。