Forgot password?
 Register account
View 249|Reply 1

一些素数的算法

[Copy link]

3153

Threads

7906

Posts

610K

Credits

Credits
64096
QQ

Show all posts

hbghlyj Posted 2023-5-8 19:58 |Read mode
AlphaExamples/Prime Numbers看到

prime closest to 169743212304
  1. ResourceFunction["ClosestPrime"][169743212304]
Copy the Code
如何获取这个ClosestPrime的源码?
想知道是什么原理

1000th twin prime
  1. ResourceFunction["TwinPrime"][1000]
Copy the Code
如何获取这个TwinPrime的源码?
想知道是什么原理

20th Mersenne prime
  1. ResourceFunction["MersennePrime"][20]
Copy the Code
如何获取这个MersennePrime的源码?
想知道是什么原理

4th Fermat prime
  1. ResourceFunction["FermatPrime"][4]
Copy the Code
如何获取这个FermatPrime的源码?
想知道是什么原理

3153

Threads

7906

Posts

610K

Credits

Credits
64096
QQ

Show all posts

 Author| hbghlyj Posted 2023-5-8 20:02
  1. In[16]:= AbsoluteTiming[ResourceFunction["ClosestPrime"][169743212304]]
  2. Out[16]= {0.0019117,169743212279}
  3. In[17]:= AbsoluteTiming[Prime[PrimePi[169743212304-1]]]
  4. Out[17]= {0.011716,169743212279}
Copy the Code
发现这个ClosestPrime比用列表的方式找素数快10倍呢

Mobile version|Discuz Math Forum

2025-6-5 01:16 GMT+8

Powered by Discuz!

× Quick Reply To Top Edit