Most viewed recipes tagged "primality_testing"http://code.activestate.com/recipes/tags/primality_testing/views/2013-12-27T06:43:59-08:00ActiveState Code RecipesPublic Key Encryption (RSA) (Python) 2012-05-12T23:34:22-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577737-public-key-encryption-rsa/ <p style="color: grey"> Python recipe 577737 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/encryption/">encryption</a>, <a href="/recipes/tags/inverse/">inverse</a>, <a href="/recipes/tags/multiplicative/">multiplicative</a>, <a href="/recipes/tags/primality_testing/">primality_testing</a>, <a href="/recipes/tags/primes/">primes</a>, <a href="/recipes/tags/publickey/">publickey</a>, <a href="/recipes/tags/rsa/">rsa</a>). Revision 2. </p> <p>Simple code to create and use public/private keypairs. Accompanied by a rudimentary encoder.</p> Find Prime Numbers in python (Python) 2010-06-12T08:22:40-07:00Giannis Fysakishttp://code.activestate.com/recipes/users/4174072/http://code.activestate.com/recipes/577259-find-prime-numbers-in-python/ <p style="color: grey"> Python recipe 577259 by <a href="/recipes/users/4174072/">Giannis Fysakis</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/primality_testing/">primality_testing</a>, <a href="/recipes/tags/prime/">prime</a>, <a href="/recipes/tags/primes/">primes</a>, <a href="/recipes/tags/prime_generator/">prime_generator</a>, <a href="/recipes/tags/prime_number/">prime_number</a>). Revision 2. </p> <p>The algorithm is based on the idea <br /> that the next larger prime after one prime is the sum of the two smaller previous minus three prime numbers back. For the first five prime numbers 2,3,5,7,11 this pattern is not true also it is not true if the number is a composite number (including of course if the number's square root is integer). </p> <p>Example trying to find the tenth prime</p> <p>so lets play with numbers 17(minus 3 from Next,position 7), 19(minus 2 from Next,position 8), 23(minus 1 from Next,position 9) and number Next at position 10 :</p> <p>hmmm ... if we add 19 and 23 we get 42, but 42 minus 17 equals 25 which isn't a prime :(</p> <p>In order to correct this we assume that 25 is the next prime number ( temporary holding the tenth position) finally to get the real Next prime number we take 23 + 25 = 48 , we subtract 19 and we get 29 which finally it takes the tenth position ( because it deserves it :P)</p> Public Key Encryption (RSA) (Python) 2013-12-27T06:43:59-08:00Mohammad Taha Jahangirhttp://code.activestate.com/recipes/users/4188847/http://code.activestate.com/recipes/578797-public-key-encryption-rsa/ <p style="color: grey"> Python recipe 578797 by <a href="/recipes/users/4188847/">Mohammad Taha Jahangir</a> (<a href="/recipes/tags/encryption/">encryption</a>, <a href="/recipes/tags/inverse/">inverse</a>, <a href="/recipes/tags/multiplicative/">multiplicative</a>, <a href="/recipes/tags/primality_testing/">primality_testing</a>, <a href="/recipes/tags/primes/">primes</a>, <a href="/recipes/tags/publickey/">publickey</a>, <a href="/recipes/tags/rsa/">rsa</a>). Revision 3. </p> <p>Simple code to create and use public/private keypairs. Accompanied by a rudimentary encoder.</p> Elliptic Curve Prime Factorisation (Python) 2011-01-17T18:42:06-08:00Mukesh Tiwarihttp://code.activestate.com/recipes/users/4172899/http://code.activestate.com/recipes/577544-elliptic-curve-prime-factorisation/ <p style="color: grey"> Python recipe 577544 by <a href="/recipes/users/4172899/">Mukesh Tiwari</a> (<a href="/recipes/tags/primality_testing/">primality_testing</a>). Revision 3. </p> <p>Hello all, I implemented this using Wikipedia [http://en.wikipedia.org/wiki/Lenstra_elliptic_curve_factorization] and some codes from google code search[extended_gcd and gcd].In my opinion, this code is not optimized and can be further improved. Feel free to post your comment. Thank You</p> Prime Number Generator Checker (Python) 2008-10-28T12:14:03-07:00TheMachineCharmerhttp://code.activestate.com/recipes/users/4167676/http://code.activestate.com/recipes/576543-prime-number-generator-checker/ <p style="color: grey"> Python recipe 576543 by <a href="/recipes/users/4167676/">TheMachineCharmer</a> (<a href="/recipes/tags/number_theory/">number_theory</a>, <a href="/recipes/tags/primality_testing/">primality_testing</a>, <a href="/recipes/tags/prime_number/">prime_number</a>). Revision 2. </p> <p>This program implements primality testing function. The function is then used to generate prime numbers in the given range.</p>