Safe prime numbers in Python

Skip Montanaro skip at pobox.com
Wed Jan 14 11:57:54 EST 2004


Ack...  I'm an idiot:

    Skip>     def safe_primes(last=1):
    Skip>         last = long((last-1)/2)   # assuming future float division...

should be         last = (last-1)//2        # doh!

    Skip>         while True:
    Skip>             last = gmpy.next_prime(last)
    Skip>             other = last * 2 + 1
    Skip>             if gmpy.is_prime(other):
    Skip>                 yield other

Skip




More information about the Python-list mailing list