Minimum value exceeding X whose count of divisors has different parity with count of divisors of X | Java program for the above approach ; 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
import java . util . * ; class GFG { static int divisorCount ( int n ) { int x = 0 ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == n / i ) x ++ ; else x += 2 ; } } return x ; } static int minvalue_y ( int x ) { int a = divisorCount ( x ) ; int y = x + 1 ; while ( ( a & 1 ) == ( divisorCount ( y ) & 1 ) ) y ++ ; return y ; } public static void main ( String [ ] args ) { int x = 5 ; System . out . println ( minvalue_y ( x ) ) ; } }