Safe prime numbers in Python

Skip Montanaro skip at
Wed Jan 14 17:57:54 CET 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


More information about the Python-list mailing list