random a 512-bit integer N that is not a multiple of 2, 3, or 5

╄→尐↘猪︶ㄣ 提交于 2019-12-01 21:08:10

The number of primes less than n=2512 is approximately n/log(n). The number of numbers you are considering is 4/15*n, so the probability you are looking for is 15/(4*log(n)), which is about 1 %.

Probability bounds

You may use the following inequality for the prime pi function:

(Where log is taken in base e)

So:

8.58774*10151 < π(2512) < 8.93096*10151

And as you are only leaving alive 4/15 n numbers (because of killing he multiples of 2, 3 and 5), te probability is bounded by:

8.58774*10151/(4/15 2512) < P < 8.93096*10151/(4/15 2512)

Or:

0.010507 < P < 0.010687

Which is a nice, pretty tight bound.

This sounds homeworkish so I suggest you generate some 512bit numbers and use some well known prime tests to get an approximate answer heuristically.

Do you want an exact answer or an approximation? For an approximation you can use the prime number theorem or prime counting function.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!