转自:http://www.cnblogs.com/linyujun/p/5198832.html
整合:https://blog.csdn.net/x_i_y_u_e/article/details/46365549
整合:https://blog.csdn.net/qq_43332305/article/details/82959066
- π(x) ,素数分布函数,为小于等于 x 的素数的个数。
- 当 x 趋于 无穷大时,π(x) 与 x / lnx等价。
- 当 x 趋于 无穷大时,1~x 中所有素数的倒数和与 $\ln \ln x$ 等价。
- factor(x) 表示x的因子个数,比如 factor(6) = 4。
素数
定义
除了1和它本身以外不再有其他的因数的数。也叫质数。
素数判定
根据素数的定义判定(复杂度$O(\sqrt{n})$)
代码如下
1 //素数 2 inline bool isPrime(const LL x) { 3 if (x <= 1)return false; 4 for (LL i = 2; i * i <= x; i++)if (x % i == 0)return false; 5 return true; 6 }