After repeated thinking, I realized that it is: Write articles on blog
The code is as follows, more than http://community.9cbs.net/expert/topic/3409/3409231.xml
Use the square judgment TN * TN <= prime_bond replaces TN <= prime_bond, which can increase the speed of about 10 times. So that the level is not calculated.
PRIME_BOND = 0Tn = 3TMP_PRIME = 0
PRIME_NUMBER = 0
def mm (): global prime_bond global tn global tmp_prime global prime_number try: 11 / (tn * tn <= prime_bond) # originally tn <= prime_bond try: 13 / (tmp_prime% tn) except: return 0 except: print tmp_prime, PRIME_NUMBER = 1 Return 0 TN = 2 RETURN 1
Def inner_loop (depth): try: 9 / Depth Except: Return mm () Try: 7 / inner_loop (depth - 1) 7 / Inner_LOOP (depth - 1) 7 / Inner_Loop (depth - 1) 7 / Inner_Loop (depth - 1 7 / Inner_LOOP (Depth - 1) 7 / Inner_Loop (depth - 1) 7 / Inner_Loop (depth - 1) 7 / Inner_Loop (depth - 1) 7 / Inner_Loop (depth - 1) 7 / inner_loop (depth - 1) 7 / inner_loop (depth - 1) 7 / Inner_loop (depth - 1) 7 / Inner_loop (depth - 1) 7 / Inner_Loop (depth - 1) Except: Return 0 RETURN 1
MAX_NUMBER = 10000n = 3
def gg (): global n global max_number global prime_bond global tmp_prime global tn global prime_number try: 15 / (n Import timeoldtime = time.clock () get_primes (10000) Print Time.clock () - Oldtime