use sieve to find prime
pm [ 0 ] , pm [ 1 ] = False , False NEW_LINE for i in range ( 2 , MAX + 1 ) : NEW_LINE INDENT if pm [ i ] == True : NEW_LINE INDENT for j in range ( 2 * i , MAX + 1 , i ) : NEW_LINE INDENT pm [ j ] = False NEW_LINE DEDENT DEDENT DEDENT