Remove those counts which have lcm as i but i is not present
factors . remove ( factors [ 0 ] ) NEW_LINE toSubtract = 1 NEW_LINE prev = 0 NEW_LINE for j in range ( len ( factors ) ) : NEW_LINE INDENT remFactors = len ( factors ) - j NEW_LINE indexes = len ( arr ) - queryBIT ( factors [ j ] - 1 ) NEW_LINE toSubtract = ( toSubtract * power ( remFactors , indexes - prev ) ) NEW_LINE prev = max ( prev , indexes ) NEW_LINE DEDENT