codeparrot/xlcost-text-to-code huggingface dataset:
Check if a N base number is Even or Odd | Java code to check if a Octal number is Even or Odd ; To return value of a char . ; Function to convert a number from N base to decimal ; power of base ; Decimal equivalent is str [ len - 1 ] * 1 + str [ len - 1 ] * base + str [ len - 1 ] * ( base ^ 2 ) + ... ; A digit in input number must be less than number 's base ; Returns true if n is even , else odd ; Driver code
import java . io . * ; class Main { static int val ( char c ) { if ( c >= '0' && c <= '9' ) return ( int ) c - '0' ; else return ( int ) c - ' A ' + 10 ; } static int toDeci ( String str , int base ) { int len = str . length ( ) ; int power = 1 ; int num = 0 ; int i ; for ( i = len - 1 ; i >= 0 ; i -- ) { if ( val ( str . charAt ( i ) ) >= base ) { System . out . println ( " Invalid ▁ Number " ) ; return - 1 ; } num += val ( str . charAt ( i ) ) * power ; power = power * base ; } return num ; } public static boolean isEven ( String num , int N ) { int deci = toDeci ( num , N ) ; return ( deci % 2 == 0 ) ; } public static void main ( String [ ] args ) { String num = "11A " ; int N = 16 ; if ( isEven ( num , N ) ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } }
Find the next Factorial greater than N | Java implementation of the above approach ; Array that stores the factorial till 20 ; Function to pre - compute the factorial till 20 ; Precomputing factorials ; Function to return the next factorial number greater than N ; Traverse the factorial array ; Find the next just greater factorial than N ; Driver Code ; Function to precalculate the factorial till 20 ; Function call
class GFG { final static int fact [ ] = new int [ 21 ] ; static void preCompute ( ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i < 18 ; i ++ ) fact [ i ] = ( fact [ i - 1 ] * i ) ; } static void nextFactorial ( int N ) { for ( int i = 0 ; i < 21 ; i ++ ) { if ( N < fact [ i ] ) { System . out . println ( fact [ i ] ) ; break ; } } } public static void main ( String [ ] args ) { preCompute ( ) ; int N = 120 ; nextFactorial ( N ) ; } }
Find K distinct positive odd integers with sum N | Java implementation to find K odd positive integers such that their sum is equal to given number ; Function to find K odd positive integers such that their sum is N ; Condition to check if there are enough values to check ; Driver Code
import java . util . * ; class GFG { static void findDistinctOddSum ( int n , int k ) { if ( ( k * k ) <= n && ( n + k ) % 2 == 0 ) { int val = 1 ; int sum = 0 ; for ( int i = 1 ; i < k ; i ++ ) { System . out . print ( val + " ▁ " ) ; sum += val ; val += 2 ; } System . out . print ( n - sum + "NEW_LINE"); } else System . out . print ( "NO NEW_LINE"); } public static void main ( String [ ] args ) { int n = 100 ; int k = 4 ; findDistinctOddSum ( n , k ) ; } }
Minimum number of operations to convert array A to array B by adding an integer into a subarray | Java implementation to find the minimum number of operations in which the array A can be converted to another array B ; Function to find the minimum number of operations in which array A can be converted to array B ; Loop to iterate over the array ; if both elements are equal then move to next element ; Calculate the difference between two elements ; loop while the next pair of elements have same difference ; Increase the number of operations by 1 ; Print the number of operations required ; Driver Code
class GFG { static void checkArray ( int a [ ] , int b [ ] , int n ) { int operations = 0 ; int i = 0 ; while ( i < n ) { if ( a [ i ] - b [ i ] == 0 ) { i ++ ; continue ; } int diff = a [ i ] - b [ i ] ; i ++ ; while ( i < n && a [ i ] - b [ i ] == diff ) { i ++ ; } operations ++ ; } System . out . println ( operations ) ; } public static void main ( String [ ] args ) { int a [ ] = { 3 , 7 , 1 , 4 , 1 , 2 } ; int b [ ] = { 3 , 7 , 3 , 6 , 3 , 2 } ; int size = a . length ; checkArray ( a , b , size ) ; } }
Perfect Cube | Java program to check if a number is a perfect cube using prime factors ; Inserts the prime factor in the Hash Map if not present If present updates it 's frequency ; A utility function to find all prime factors of a given number N ; Insert the number of 2 s that divide n ; n must be odd at this point . So we can skip one element ; While i divides n , insert i and divide n ; This condition is to handle the case when n is a prime number greater than 2 ; Function to check if a number is a perfect cube ; Using values ( ) for iteration over keys ; Driver Code ; Function to check if N is perfect cube or not
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { public static HashMap < Integer , Integer > insertPF ( HashMap < Integer , Integer > primeFact , int fact ) { if ( primeFact . containsKey ( fact ) ) { int freq ; freq = primeFact . get ( fact ) ; primeFact . replace ( fact , ++ freq ) ; } else { primeFact . put ( fact , 1 ) ; } return primeFact ; } public static HashMap < Integer , Integer > primeFactors ( int n ) { HashMap < Integer , Integer > primeFact = new HashMap < > ( ) ; while ( n % 2 == 0 ) { primeFact = insertPF ( primeFact , 2 ) ; n /= 2 ; } for ( int i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { while ( n % i == 0 ) { primeFact = insertPF ( primeFact , i ) ; n /= i ; } } if ( n > 2 ) primeFact = insertPF ( primeFact , n ) ; return primeFact ; } public static String perfectCube ( int n ) { HashMap < Integer , Integer > primeFact ; primeFact = primeFactors ( n ) ; for ( int freq : primeFact . values ( ) ) { if ( freq % 3 != 0 ) return " No " ; } return " Yes " ; } public static void main ( String [ ] args ) { int N = 216 ; System . out . println ( perfectCube ( N ) ) ; } }
Count ways to reach the Nth stair using multiple 1 or 2 steps and a single step 3 | Java implementation to find the number the number of ways to reach Nth stair by taking 1 or 2 steps at a time and 3 rd step exactly once ; Single line to find factorial ; Function to find the number of ways ; Base Case ; Count of 2 - steps ; Count of 1 - steps ; Initial length of sequence ; Expected count of 2 - steps ; Loop to find the ways for every possible sequence ; Driver Code
class GFG { static int factorial ( int n ) { return ( n == 1 n == 0 ) ? 1 : n * factorial ( n - 1 ) ; } static int ways ( int n ) { if ( n < 3 ) { return 0 ; } int c2 = 0 ; int c1 = n - 3 ; int l = c1 + 1 ; int s = 0 ; int exp_c2 = c1 / 2 ; while ( exp_c2 >= c2 ) { int f1 = factorial ( l ) ; int f2 = factorial ( c1 ) ; int f3 = factorial ( c2 ) ; int f4 = ( f2 * f3 ) ; s += f1 / f4 ; c2 += 1 ; c1 -= 2 ; l -= 1 ; } return s ; } public static void main ( String args [ ] ) { int n = 7 ; int ans = ways ( n ) ; System . out . println ( ans ) ; } }
Find N from the value of N ! | Java program to find a number such that the factorial of that number is given ; Map to precompute and store the factorials of the numbers ; Function to precompute factorial ; Calculating the factorial for each i and storing in a map ; Driver code ; Precomputing the factorials
import java . util . * ; class GFG { static Map < Integer , Integer > m = new HashMap < Integer , Integer > ( ) ; static void precompute ( ) { int fact = 1 ; for ( int i = 1 ; i <= 18 ; i ++ ) { fact = fact * i ; m . put ( fact , i ) ; } } public static void main ( String [ ] args ) { precompute ( ) ; int K = 120 ; System . out . print ( m . get ( K ) + "NEW_LINE"); K = 6 ; System . out . print ( m . get ( K ) + "NEW_LINE"); } }
Count of Leap Years in a given year range | Java implementation to find the count of leap years in given range of the year ; Function to calculate the number of leap years in range of ( 1 , year ) ; Function to calculate the number of leap years in given range ; Driver Code
class GFG { static int calNum ( int year ) { return ( year / 4 ) - ( year / 100 ) + ( year / 400 ) ; } static void leapNum ( int l , int r ) { l -- ; int num1 = calNum ( r ) ; int num2 = calNum ( l ) ; System . out . print ( num1 - num2 + "NEW_LINE"); } public static void main ( String [ ] args ) { int l1 = 1 , r1 = 400 ; leapNum ( l1 , r1 ) ; int l2 = 400 , r2 = 2000 ; leapNum ( l2 , r2 ) ; } }
Ternary representation of Cantor set | Java implementation to find the cantor set for n levels and for a given start_num and end_num ; The Linked List Structure for the Cantor Set ; Function to initialize the Cantor Set List ; Function to propogate the list by adding new nodes for the next levels ; Modifying the start and end values for the next level ; Changing the pointers to the next node ; Recursively call the function to generate the Cantor Set for the entire level ; Function to print a level of the Set ; Function to build and display the Cantor Set for each level ; Driver code
class GFG { static class Cantor { double start , end ; Cantor next ; } ; static Cantor Cantor ; static Cantor startList ( Cantor head , double start_num , double end_num ) { if ( head == null ) { head = new Cantor ( ) ; head . start = start_num ; head . end = end_num ; head . next = null ; } return head ; } static Cantor propagate ( Cantor head ) { Cantor temp = head ; if ( temp != null ) { Cantor newNode = new Cantor ( ) ; double diff = ( ( ( temp . end ) - ( temp . start ) ) / 3 ) ; newNode . end = temp . end ; temp . end = ( ( temp . start ) + diff ) ; newNode . start = ( newNode . end ) - diff ; newNode . next = temp . next ; temp . next = newNode ; propagate ( temp . next . next ) ; } return head ; } static void print ( Cantor temp ) { while ( temp != null ) { System . out . printf ( " [ % f ] ▁ - - ▁ [ % f ] " , temp . start , temp . end ) ; temp = temp . next ; } System . out . printf ( "NEW_LINE"); } static void buildCantorSet ( int A , int B , int L ) { Cantor head = null ; head = startList ( head , A , B ) ; for ( int i = 0 ; i < L ; i ++ ) { System . out . printf ( " Level _ % d ▁ : ▁ " , i ) ; print ( head ) ; propagate ( head ) ; } System . out . printf ( " Level _ % d ▁ : ▁ " , L ) ; print ( head ) ; } public static void main ( String [ ] args ) { int A = 0 ; int B = 9 ; int L = 2 ; buildCantorSet ( A , B , L ) ; } }
Find sum of f ( s ) for all the chosen sets from the given array | Java implementation of the approach ; To store the factorial and the factorial mod inverse of a number ; Function to find ( a ^ m1 ) % mod ; Function to find factorial of all the numbers ; Function to find the factorial mod inverse of all the numbers ; Function to return nCr ; Function to find sum of f ( s ) for all the chosen sets from the given array ; Sort the given array ; Calculate the factorial and modinverse of all elements ; For all the possible sets Calculate max ( S ) and min ( S ) ; Driver code
import java . util . * ; class GFG { static int N = 100005 ; static int mod = 1000000007 ; static int temp = 391657242 ; static int [ ] factorial = new int [ N ] ; static int [ ] modinverse = new int [ N ] ; static int power ( int a , int m1 ) { if ( m1 == 0 ) return 1 ; else if ( m1 == 1 ) return a ; else if ( m1 == 2 ) return ( a * a ) % mod ; else if ( ( m1 & 1 ) != 0 ) return ( a * power ( power ( a , m1 / 2 ) , 2 ) ) % mod ; else return power ( power ( a , m1 / 2 ) , 2 ) % mod ; } static void factorialfun ( ) { factorial [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) factorial [ i ] = ( factorial [ i - 1 ] * i ) % mod ; } static void modinversefun ( ) { modinverse [ N - 1 ] = power ( factorial [ N - 1 ] , mod - 2 ) % mod ; for ( int i = N - 2 ; i >= 0 ; i -- ) modinverse [ i ] = ( modinverse [ i + 1 ] * ( i + 1 ) ) % mod ; } static int binomial ( int n , int r ) { if ( r > n ) return 0 ; int a = ( factorial [ n ] * modinverse [ n - r ] ) % mod ; a = ( a * modinverse [ r ] ) % mod ; return a ; } static int max_min ( int a [ ] , int n , int k ) { Arrays . sort ( a ) ; factorialfun ( ) ; modinversefun ( ) ; int ans = 0 ; k -- ; for ( int i = 0 ; i < n ; i ++ ) { int x = n - i - 1 ; if ( x >= k ) ans -= binomial ( x , k ) * a [ i ] % mod ; int y = i ; if ( y >= k ) ans += binomial ( y , k ) * a [ i ] % mod ; ans = ( ans + mod ) % mod ; } return ans % temp ; } public static void main ( String args [ ] ) { int [ ] a = { 1 , 1 , 3 , 4 } ; int k = 2 ; int n = a . length ; System . out . println ( max_min ( a , n , k ) ) ; } }
Length of Smallest subarray in range 1 to N with sum greater than a given value | Java implementation of the above implementation ; Function to return the count of minimum elements such that the sum of those elements is > S . ; Initialize currentSum = 0 ; Loop from N to 1 to add the numbers and check the condition . ; Driver code
class GFG { static int countNumber ( int N , int S ) { int countElements = 0 ; int currSum = 0 ; while ( currSum <= S ) { currSum += N ; N -- ; countElements ++ ; } return countElements ; } public static void main ( String [ ] args ) { int N , S ; N = 5 ; S = 11 ; int count = countNumber ( N , S ) ; System . out . println ( count ) ; } }
Next Number with distinct digits | Java program to find next consecutive Number with all distinct digits ; Function to count distinct digits in a number ; To count the occurrence of digits in number from 0 to 9 ; Iterate over the digits of the number Flag those digits as found in the array ; Traverse the array arr and count the distinct digits in the array ; Function to return the total number of digits in the number ; Iterate over the digits of the number ; Function to return the next number with distinct digits ; Count the distinct digits in N + 1 ; Count the total number of digits in N + 1 ; Return the next consecutive number ; Increment Number by 1 ; Driver code
class GFG { final static int INT_MAX = Integer . MAX_VALUE ; static int countDistinct ( int n ) { int arr [ ] = new int [ 10 ] ; int count = 0 ; while ( n != 0 ) { int r = n % 10 ; arr [ r ] = 1 ; n /= 10 ; } for ( int i = 0 ; i < 10 ; i ++ ) { if ( arr [ i ] != 0 ) count ++ ; } return count ; } static int countDigit ( int n ) { int c = 0 ; while ( n != 0 ) { int r = n % 10 ; c ++ ; n /= 10 ; } return c ; } static int nextNumberDistinctDigit ( int n ) { while ( n < INT_MAX ) { int distinct_digits = countDistinct ( n + 1 ) ; int total_digits = countDigit ( n + 1 ) ; if ( distinct_digits == total_digits ) { return n + 1 ; } else n ++ ; } return - 1 ; } public static void main ( String [ ] args ) { int n = 2019 ; System . out . println ( nextNumberDistinctDigit ( n ) ) ; } }
Minimum possible sum of array B such that AiBi = AjBj for all 1 â ‰¤ i < j â ‰¤ N | Java implementation of the approach ; To store least prime factors of all the numbers ; Function to find the least prime factor of all the numbers ; Function to return the ( ( a ^ m1 ) % mod ) ; Function to return the sum of elements of array B ; Find the prime factors of all the numbers ; To store each prime count in lcm ; Current number ; Map to store the prime count of a single number ; Basic way to calculate all prime factors ; If it is the first number in the array ; Take the maximum count of prime in a number ; Calculate lcm of given array ; Calculate sum of elements of array B ; Driver code
import java . util . * ; class GFG { static int mod = 1000000007 ; static int N = 1000005 ; static int lpf [ ] = new int [ N ] ; static void least_prime_factor ( ) { for ( int i = 1 ; i < N ; i ++ ) lpf [ i ] = i ; for ( int i = 2 ; i < N ; i ++ ) if ( lpf [ i ] == i ) for ( int j = i * 2 ; j < N ; j += i ) if ( lpf [ j ] == j ) lpf [ j ] = i ; } static long power ( long a , long m1 ) { if ( m1 == 0 ) return 1 ; else if ( m1 == 1 ) return a ; else if ( m1 == 2 ) return ( 1l * a * a ) % mod ; else if ( ( m1 & 1 ) != 0 ) return ( 1l * a * power ( power ( a , m1 / 2 ) , 2 ) ) % mod ; else return power ( power ( a , m1 / 2 ) , 2 ) % mod ; } static long sum_of_elements ( long a [ ] , int n ) { least_prime_factor ( ) ; HashMap < Long , Long > prime_factor = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { long temp = a [ i ] ; HashMap < Long , Long > single_number = new HashMap < > ( ) ; while ( temp > 1 ) { long x = lpf [ ( int ) temp ] ; single_number . put ( x , ( single_number . get ( x ) == null ? 1 : single_number . get ( x ) + 1 ) ) ; temp /= x ; } if ( i == 0 ) prime_factor = single_number ; else { for ( Map . Entry < Long , Long > x : single_number . entrySet ( ) ) prime_factor . put ( x . getKey ( ) , Math . max ( x . getValue ( ) , ( prime_factor . get ( x . getKey ( ) ) == null ? 0 : prime_factor . get ( x . getKey ( ) ) ) ) ) ; } } long ans = 0 , lcm = 1 ; for ( Map . Entry < Long , Long > x : prime_factor . entrySet ( ) ) lcm = ( lcm * power ( x . getKey ( ) , x . getValue ( ) ) ) % mod ; for ( int i = 0 ; i < n ; i ++ ) ans = ( ans + ( lcm * power ( a [ i ] , mod - 2 ) ) % mod ) % mod ; return ans ; } public static void main ( String args [ ] ) { long a [ ] = { 2 , 3 , 4 } ; int n = a . length ; System . out . println ( sum_of_elements ( a , n ) ) ; } }
Find Number of Even cells in a Zero Matrix after Q queries | Java program find Number of Even cells in a Zero Matrix after Q queries ; Function to find the number of even cell in a 2D matrix ; Maintain two arrays , one for rows operation and one for column operation ; Increment operation on row [ i ] ; Increment operation on col [ i ] ; Count odd and even values in both arrays and multiply them ; Count of rows having even numbers ; Count of rows having odd numbers ; Count of columns having even numbers ; Count of columns having odd numbers ; Driver code
class GFG { static int findNumberOfEvenCells ( int n , int q [ ] [ ] , int size ) { int row [ ] = new int [ n ] ; int col [ ] = new int [ n ] ; for ( int i = 0 ; i < size ; i ++ ) { int x = q [ i ] [ 0 ] ; int y = q [ i ] [ 1 ] ; row [ x - 1 ] ++ ; col [ y - 1 ] ++ ; } int r1 = 0 , r2 = 0 ; int c1 = 0 , c2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( row [ i ] % 2 == 0 ) { r1 ++ ; } if ( row [ i ] % 2 == 1 ) { r2 ++ ; } if ( col [ i ] % 2 == 0 ) { c1 ++ ; } if ( col [ i ] % 2 == 1 ) { c2 ++ ; } } int count = r1 * c1 + r2 * c2 ; return count ; } public static void main ( String [ ] args ) { int n = 2 ; int q [ ] [ ] = { { 1 , 1 } , { 1 , 2 } , { 2 , 1 } } ; int size = q . length ; System . out . println ( findNumberOfEvenCells ( n , q , size ) ) ; } }
Find maximum unreachable height using two ladders | Java implementation of the approach ; Function to return the maximum height which can 't be reached ; Driver code
class GFG { static int maxHeight ( int h1 , int h2 ) { return ( ( h1 * h2 ) - h1 - h2 ) ; } public static void main ( String args [ ] ) { int h1 = 7 , h2 = 5 ; System . out . println ( Math . max ( 0 , maxHeight ( h1 , h2 ) ) ) ; } }
Fermat 's Factorization Method | Java implementation of fermat 's factorization ; This function finds the value of a and b and returns a + b and a - b ; since fermat 's factorization applicable  for odd positive integers only ; check if n is a even number ; if n is a perfect root , then both its square roots are its factors ; Driver Code
class GFG { static void FermatFactors ( int n ) { if ( n <= 0 ) { System . out . print ( " [ " + n + " ] " ) ; return ; } if ( ( n & 1 ) == 0 ) { System . out . print ( " [ " + n / 2.0 + " , " + 2 + " ] " ) ; return ; } int a = ( int ) Math . ceil ( Math . sqrt ( n ) ) ; if ( a * a == n ) { System . out . print ( " [ " + a + " , " + a + " ] " ) ; return ; } int b ; while ( true ) { int b1 = a * a - n ; b = ( int ) ( Math . sqrt ( b1 ) ) ; if ( b * b == b1 ) break ; else a += 1 ; } System . out . print ( " [ " + ( a - b ) + " , " + ( a + b ) + " ] " ) ; return ; } public static void main ( String [ ] args ) { FermatFactors ( 6557 ) ; } }
Append two elements to make the array satisfy the given condition | Java implementation of the approach ; Function to find the required numbers ; Find the sum and xor ; Print the required elements ; Driver code
class GFG { static void findNums ( int arr [ ] , int n ) { int S = 0 , X = 0 ; for ( int i = 0 ; i < n ; i ++ ) { S += arr [ i ] ; X ^= arr [ i ] ; } System . out . println ( X + " ▁ " + ( X + S ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 7 } ; int n = arr . length ; findNums ( arr , n ) ; } }
Satisfy the parabola when point ( A , B ) and the equation is given | Java implementation of the approach ; Function to find the required values ; Driver code
class GFG { static void solve ( int A , int B ) { double p = B / 2.0 ; double M = Math . ceil ( 4 * p ) ; int N = 1 ; int O = - 2 * A ; double Q = Math . ceil ( A * A + 4 * p * p ) ; System . out . println ( M + " ▁ " + N + " ▁ " + O + " ▁ " + Q ) ; } public static void main ( String [ ] args ) { int a = 1 ; int b = 1 ; solve ( a , b ) ; } }
Largest number dividing maximum number of elements in the array | Java implementation of the approach ; Function to return the largest number that divides the maximum elements from the given array ; Finding gcd of all the numbers in the array ; Driver code
class GFG { static int findLargest ( int [ ] arr , int n ) { int gcd = 0 ; for ( int i = 0 ; i < n ; i ++ ) gcd = __gcd ( arr [ i ] , gcd ) ; return gcd ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 6 , 9 } ; int n = arr . length ; System . out . print ( findLargest ( arr , n ) ) ; } }
Check if the sum of digits of N is palindrome | Java implementation of the approach ; Function to return the sum of digits of n ; Function that returns true if n is palindrome ; Find the appropriate divisor to extract the leading digit ; If first and last digit not same return false ; Removing the leading and trailing digit from number ; Reducing divisor by a factor of 2 as 2 digits are dropped ; Function that returns true if the digit sum of n is palindrome ; Sum of the digits of n ; If the digit sum is palindrome ; Driver code
import java . util . * ; class GFG { static int digitSum ( int n ) { int sum = 0 ; while ( n > 0 ) { sum += ( n % 10 ) ; n /= 10 ; } return sum ; } static boolean isPalindrome ( int n ) { int divisor = 1 ; while ( n / divisor >= 10 ) divisor *= 10 ; while ( n != 0 ) { int leading = n / divisor ; int trailing = n % 10 ; if ( leading != trailing ) return false ; n = ( n % divisor ) / 10 ; divisor = divisor / 100 ; } return true ; } static boolean isDigitSumPalindrome ( int n ) { int sum = digitSum ( n ) ; if ( isPalindrome ( sum ) ) return true ; return false ; } public static void main ( String [ ] args ) { int n = 56 ; if ( isDigitSumPalindrome ( n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }
Find the value of N XOR 'ed to itself K times | Java implementation of the approach ; Function to return n ^ n ^ ... k times ; If k is odd the answer is the number itself ; Else the answer is 0 ; Driver code
class GFG { static int xorK ( int n , int k ) { if ( k % 2 == 1 ) return n ; return 0 ; } public static void main ( String [ ] args ) { int n = 123 , k = 3 ; System . out . print ( xorK ( n , k ) ) ; } }