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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处