#!/usr/bin/env python # # Simple program to compute the biggest twin prime pair less than each # power of 2. # # This is used to choose "good" sizes for the hashtable. # # Using a prime for "num_slot" is useful as that guarantees that the # orbit touches every slot (which is useful to have a good # implementation of open addressing, because this means that as long # as you have free slots, you can add elements, no matter what their # hash is). # # Using a prime for the linear offset is not actually needed, but # avoiding composite numbers is usually a good idea, because they tend # to show bad behavior depending on the patterns found in the input # data. # def isprime(x): d = 2 while d * d <= x: if x % d == 0: return False d = d + 1 return True for i in range(3, 33): x = 2 ** i while not (isprime(x) and isprime(x-2)): x = x - 1 print " %d," % x