Function to calculate smallest prime factor of N .
def calculate_SPF ( ) : NEW_LINE INDENT for i in range ( MAX + 1 ) : NEW_LINE INDENT spf [ i ] = i ; NEW_LINE DEDENT for i in range ( 4 , MAX + 1 , 2 ) : NEW_LINE INDENT spf [ i ] = 2 ; NEW_LINE DEDENT i = 3 NEW_LINE while ( i * i <= MAX ) : NEW_LINE INDENT if ( spf [ i ] == i ) NEW_LINE INDENT j = i * i NEW_LINE while ( j <= MAX ) : NEW_LINE DEDENT DEDENT DEDENT