MATLAB ヘルプ センター
nth prime number
nthprime(n)
nthprime(n) returns the nth prime number. nthprime acts element-wise on array inputs.
n
nthprime
example
collapse all
Find the 223rd prime number.
nthprime(223)
ans = 1409
For large prime numbers, return exact symbolic integers by using symbolic input.
n = sym(223222222); nthprime(n)
ans = 4738278383
Find the 10th, 100th, and 1000th prime numbers.
n = [10 100 1000]; nthprime(n)
ans = 29 541 7919
Generate a random prime number between the 100,000th and 200,000th prime numbers.
rng default % for reproducibility range = [100000 200000]; nthprime(randi(range))
ans = 2476423
Input, specified as a number, vector, matrix, array, or a symbolic number or array. n must be a positive integer.
Introduced in R2018a
nextprime | prevprime
nextprime
prevprime
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
ヨーロッパ
アジア太平洋地域
最寄りの営業オフィスへのお問い合わせ