Minimum value exceeding X whose count of divisors has different parity with count of divisors of X | Function to count divisors of n ; Function to find the minimum value exceeding x whose count of divisors has different parity with count of divisors of X ; Divisor count of x ; Iterate from x + 1 and check for each element ; Driver Code ; Given X ; Function call
def divisorCount ( n ) : NEW_LINE INDENT x = 0 ; NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT if ( i == n // i ) : NEW_LINE INDENT x += 1 ; NEW_LINE DEDENT else : NEW_LINE INDENT x += 2 ; NEW_LINE DEDENT DEDENT if ( i * i > n ) : NEW_LINE INDENT break ; NEW_LINE DEDENT DEDENT return x ; NEW_LINE DEDENT def minvalue_y ( x ) : NEW_LINE INDENT a = divisorCount ( x ) ; NEW_LINE y = x + 1 ; NEW_LINE while ( ( a & 1 ) == ( divisorCount ( y ) & 1 ) ) : NEW_LINE INDENT y += 1 ; NEW_LINE DEDENT return y ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT x = 5 ; NEW_LINE print ( minvalue_y ( x ) ) ; NEW_LINE DEDENT