codeparrot/xlcost-text-to-code huggingface dataset:
Check if a N base number is Even or Odd | C # 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
using System ; class Gfg { 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_var ) { int len = str . Length ; int power = 1 ; int num = 0 ; int i ; for ( i = len - 1 ; i >= 0 ; i -- ) { if ( val ( str [ i ] ) >= base_var ) { Console . WriteLine ( " Invalid ▁ Number " ) ; return - 1 ; } num += val ( str [ i ] ) * power ; power = power * base_var ; } return num ; } public static bool 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 ) ) { Console . WriteLine ( " Even " ) ; } else { Console . WriteLine ( " Odd " ) ; } } }
Find the next Factorial greater than N | C # 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
using System ; class GFG { 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 ] ) { Console . WriteLine ( fact [ i ] ) ; break ; } } } public static void Main ( string [ ] args ) { preCompute ( ) ; int N = 120 ; nextFactorial ( N ) ; } }
Find K distinct positive odd integers with sum N | C # 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
using System ; public 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 ++ ) { Console . Write ( val + " ▁ " ) ; sum += val ; val += 2 ; } Console . Write ( n - sum + " STRNEWLINE " ) ; } else Console . Write ( " NO ▁ STRNEWLINE " ) ; } 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 | C # 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
using System ; 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 ++ ; } Console . WriteLine ( 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 | C # 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
using System ; using System . Collections . Generic ; public class GFG { public static Dictionary < int , int > insertPF ( Dictionary < int , int > primeFact , int fact ) { if ( primeFact . ContainsKey ( fact ) ) { int freq ; freq = primeFact [ fact ] ; primeFact [ fact ] = ++ freq ; } else { primeFact . Add ( fact , 1 ) ; } return primeFact ; } public static Dictionary < int , int > primeFactors ( int n ) { Dictionary < int , int > primeFact = new Dictionary < int , int > ( ) ; 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 ) { Dictionary < int , int > primeFact ; primeFact = primeFactors ( n ) ; foreach ( int freq in primeFact . Values ) { if ( freq % 3 != 0 ) return " No " ; } return " Yes " ; } public static void Main ( String [ ] args ) { int N = 216 ; Console . WriteLine ( perfectCube ( N ) ) ; } }
Count ways to reach the Nth stair using multiple 1 or 2 steps and a single step 3 | C # 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
using System ; 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 ; } static void Main ( ) { int n = 7 ; int ans = ways ( n ) ; Console . WriteLine ( ans ) ; } }
Find N from the value of N ! | C # 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
using System ; using System . Collections . Generic ; class GFG { static Dictionary < int , int > m = new Dictionary < int , int > ( ) ; static void precompute ( ) { int fact = 1 ; for ( int i = 1 ; i <= 18 ; i ++ ) { fact = fact * i ; m . Add ( fact , i ) ; } } public static void Main ( String [ ] args ) { precompute ( ) ; int K = 120 ; Console . Write ( m [ K ] + " STRNEWLINE " ) ; K = 6 ; Console . Write ( m [ K ] + " STRNEWLINE " ) ; } }
Count of Leap Years in a given year range | C # 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
using System ; 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 ) ; Console . Write ( num1 - num2 + " STRNEWLINE " ) ; } 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 | C # 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
using System ; class GFG { class Cantor { public double start , end ; public 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 ) { Console . Write ( " [ { 0 : F6 } ] ▁ - - ▁ [ { 1 : F6 } ] " , temp . start , temp . end ) ; temp = temp . next ; } Console . Write ( " STRNEWLINE " ) ; } static void buildCantorSet ( int A , int B , int L ) { Cantor head = null ; head = startList ( head , A , B ) ; for ( int i = 0 ; i < L ; i ++ ) { Console . Write ( " Level _ { 0 } ▁ : ▁ " , i ) ; print ( head ) ; propagate ( head ) ; } Console . Write ( " Level _ { 0 } ▁ : ▁ " , 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 | C # 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
using System ; 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 ) { Array . 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 ; Console . WriteLine ( max_min ( a , n , k ) ) ; } }
Length of Smallest subarray in range 1 to N with sum greater than a given value | C # 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
using System ; 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 ( ) { int N , S ; N = 5 ; S = 11 ; int count = countNumber ( N , S ) ; Console . WriteLine ( count ) ; } }
Next Number with distinct digits | C # 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
using System ; class GFG { readonly static int INT_MAX = int . MaxValue ; 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 ; Console . WriteLine ( nextNumberDistinctDigit ( n ) ) ; } }
Minimum possible sum of array B such that AiBi = AjBj for all 1 â ‰¤ i < j â ‰¤ N | C # 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
using System ; using System . Collections . Generic ; 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 ( 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 long sum_of_elements ( long [ ] a , int n ) { least_prime_factor ( ) ; Dictionary < long , long > prime_factor = new Dictionary < long , long > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { long temp = a [ i ] ; Dictionary < long , long > single_number = new Dictionary < long , long > ( ) ; while ( temp > 1 ) { long x = lpf [ ( int ) temp ] ; if ( single_number . ContainsKey ( x ) ) { single_number [ x ] ++ ; } else { single_number [ x ] = 1 ; } temp /= x ; } if ( i == 0 ) prime_factor = single_number ; else { foreach ( KeyValuePair < long , long > ele in single_number ) { if ( prime_factor . ContainsKey ( ele . Key ) ) { prime_factor [ ele . Key ] = Math . Max ( ele . Value , prime_factor [ ele . Key ] ) ; } else { prime_factor [ ele . Key ] = Math . Max ( ele . Value , 0 ) ; } } } } long ans = 0 , lcm = 1 ; foreach ( KeyValuePair < long , long > x in prime_factor ) { lcm = ( lcm * power ( x . Key , x . Value ) ) % 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 ; Console . Write ( sum_of_elements ( a , n ) ) ; } }
Find Number of Even cells in a Zero Matrix after Q queries | C # 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
using System ; 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 ( ) { int n = 2 ; int [ , ] q = { { 1 , 1 } , { 1 , 2 } , { 2 , 1 } } ; int size = q . GetLength ( 0 ) ; Console . WriteLine ( findNumberOfEvenCells ( n , q , size ) ) ; } }
Find maximum unreachable height using two ladders | C # implementation of the approach ; Function to return the maximum height which can 't be reached ; Driver code
using System ; class GFG { static int maxHeight ( int h1 , int h2 ) { return ( ( h1 * h2 ) - h1 - h2 ) ; } public static void Main ( ) { int h1 = 7 , h2 = 5 ; Console . WriteLine ( Math . Max ( 0 , maxHeight ( h1 , h2 ) ) ) ; } }
Fermat 's Factorization Method | C # 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
using System ; class GFG { static void FermatFactors ( int n ) { if ( n <= 0 ) { Console . Write ( " [ " + n + " ] " ) ; return ; } if ( ( n & 1 ) == 0 ) { Console . Write ( " [ " + n / 2.0 + " , " + 2 + " ] " ) ; return ; } int a = ( int ) Math . Ceiling ( Math . Sqrt ( n ) ) ; if ( a * a == n ) { Console . Write ( " [ " + 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 ; } Console . Write ( " [ " + ( a - b ) + " , " + ( a + b ) + " ] " ) ; return ; } public static void Main ( ) { FermatFactors ( 6557 ) ; } }
Append two elements to make the array satisfy the given condition | C # implementation of the approach ; Function to find the required numbers ; Find the sum and xor ; Print the required elements ; Driver code
using System ; 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 ] ; } Console . WriteLine ( X + " ▁ " + ( X + S ) ) ; } public static void Main ( ) { int [ ] arr = { 1 , 7 } ; int n = arr . Length ; findNums ( arr , n ) ; } }
Satisfy the parabola when point ( A , B ) and the equation is given | C # implementation of the approach ; Function to find the required values ; Driver code
using System ; class GFG { static void solve ( int A , int B ) { double p = B / 2.0 ; double M = Math . Ceiling ( 4 * p ) ; int N = 1 ; int O = - 2 * A ; double Q = Math . Ceiling ( A * A + 4 * p * p ) ; Console . Write ( M + " ▁ " + N + " ▁ " + O + " ▁ " + Q ) ; } static public void Main ( ) { int a = 1 ; int b = 1 ; solve ( a , b ) ; } }
Largest number dividing maximum number of elements in the array | C # 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
using System ; 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 ; Console . Write ( findLargest ( arr , n ) ) ; } }
Check if the sum of digits of N is palindrome | C # 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
using System ; class GFG { static int digitSum ( int n ) { int sum = 0 ; while ( n > 0 ) { sum += ( n % 10 ) ; n /= 10 ; } return sum ; } static bool 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 bool isDigitSumPalindrome ( int n ) { int sum = digitSum ( n ) ; if ( isPalindrome ( sum ) ) return true ; return false ; } static public void Main ( ) { int n = 56 ; if ( isDigitSumPalindrome ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }
Find the value of N XOR 'ed to itself K times | C # 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
using System ; 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 ; Console . Write ( xorK ( n , k ) ) ; } }