====== 素数/质数测试算法和Python代码 ====== 素数也叫做质数,是只能被1和自身整除的数。比如2,3,5,7,11等。 素数的判断也就是确定一个数是否为素数的过程。根据素数的定义,想要测试一个数n是否为素数的可以用2~(n-1)来整除这个数,如果可以被除尽,那么就不是素数。 ===== 素数判断方法一 ===== ===== 素数判断方法二 ===== ===== 素数判断方法三 ===== ===== 素数判断参考 ===== * http://www.codeproject.com/Articles/691200/Primality-test-algorithms-Prime-test-The-fastest-w * http://en.wikipedia.org/wiki/Fermat_primality_test * http://en.wikipedia.org/wiki/Primality_test * http://blog.csdn.net/lokibalder/article/details/3344439 * http://cr.yp.to/primegen.html * http://stackoverflow.com/questions/453793/which-is-the-fastest-algorithm-to-find-prime-numbers http://primesieve.org/