Keep dividing n by least prime factor while either n is not 1 or count of prime factors is not k .
while ( n > 1 ) : NEW_LINE INDENT if ( k == 1 ) : NEW_LINE INDENT return s [ n ] NEW_LINE DEDENT DEDENT