If prime is a factor of n then increment count
if ( n % prime [ i ] == 0 ) : NEW_LINE INDENT a [ j ] = prime [ i ] NEW_LINE j += 1 NEW_LINE DEDENT while ( n % prime [ i ] == 0 ) : NEW_LINE INDENT n //= prime [ i ] NEW_LINE DEDENT i += 1 NEW_LINE if ( n != 1 ) : NEW_LINE a [ j ] = n NEW_LINE j += 1 NEW_LINE return m - count ( a , j , m ) NEW_LINE def countRelPrimeInRange ( n , l , r ) : NEW_LINE sieve ( floor ( sqrt ( maxN ) ) ) NEW_LINE result = ( countRelPrime ( n , r ) - countRelPrime ( n , l - 1 ) ) NEW_LINE print ( result ) NEW_LINE