codeparrot/xlcost-text-to-code huggingface dataset:
Count of all possible pairs of disjoint subsets of integers from 1 to N | C # implementation of the approach ; Modulo exponentiation function ; Function to calculate ( x ^ y ) % p in O ( log ( y ) ) ; Driver Code ; Evaluating ( ( 3 ^ n - 2 ^ ( n + 1 ) + 1 ) / 2 ) % p ; From Fermats 's little theorem  a^-1 ? a^(m-2) (mod m)
using System ; class GFG { static int p = 1000000007 ; static long power ( long x , long y ) { long res = 1 ; x = x % p ; while ( y > 0 ) { if ( y % 2 == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res % p ; } static public void Main ( ) { long n = 3 ; long x = ( power ( 3 , n ) % p + 1 ) % p ; x = ( x - power ( 2 , n + 1 ) + p ) % p ; x = ( x * power ( 2 , p - 2 ) ) % p ; Console . Write ( x ) ; } }
Right most non | C # implementation of the approach ; Function to return the rightmost non - zero digit in the multiplication of the array elements ; To store the count of times 5 can divide the array elements ; Divide the array elements by 5 as much as possible ; increase count of 5 ; Divide the array elements by 2 as much as possible ; Decrease count of 5 , because a '2' and a '5' makes a number with last digit '0' ; If c5 is more than the multiplier should be taken as 5 ; Driver code
using System ; class GFG { static int rightmostNonZero ( int [ ] a , int n ) { int c5 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( a [ i ] > 0 && a [ i ] % 5 == 0 ) { a [ i ] /= 5 ; c5 ++ ; } } for ( int i = 0 ; i < n ; i ++ ) { while ( c5 != 0 && a [ i ] > 0 && ( a [ i ] & 1 ) == 0 ) { a [ i ] >>= 1 ; c5 -- ; } } int ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { ans = ( ans * a [ i ] % 10 ) % 10 ; } if ( c5 != 0 ) ans = ( ans * 5 ) % 10 ; if ( ans != 0 ) return ans ; return - 1 ; } public static void Main ( ) { int [ ] a = { 7 , 42 , 11 , 64 } ; int n = a . Length ; Console . WriteLine ( rightmostNonZero ( a , n ) ) ; } }
Find the remainder when First digit of a number is divided by its Last digit | C # program to find the remainder when the First digit of a number is divided by its Last digit ; Function to find the remainder ; Get the last digit ; Get the first digit ; Compute the remainder ; Driver code
using System ; class GFG { static void findRemainder ( int n ) { int l = n % 10 ; while ( n >= 10 ) n /= 10 ; int f = n ; int remainder = f % l ; Console . WriteLine ( remainder ) ; } public static void Main ( ) { int n = 5223 ; findRemainder ( n ) ; } }
Percentage increase in the volume of cuboid if length , breadth and height are increased by fixed percentages | C # implementation of the approach ; Function to return the percentage increase in the volume of the cuboid ; Driver code
using System ; class GFG { static double increaseInVol ( double l , double b , double h ) { double percentInc = ( 1 + ( l / 100 ) ) * ( 1 + ( b / 100 ) ) * ( 1 + ( h / 100 ) ) ; percentInc -= 1 ; percentInc *= 100 ; return percentInc ; } public static void Main ( ) { double l = 50 , b = 20 , h = 10 ; Console . WriteLine ( increaseInVol ( l , b , h ) + " % " ) ; } }
Count the number of occurrences of a particular digit in a number | C # program to count the number of occurrences of a particular digit in a number ; Function to count the occurrences of the digit D in N ; Loop to find the digits of N ; check if the digit is D ; return the count of the occurrences of D in N ; Driver code
using System ; class GFG { static int countOccurrances ( int n , int d ) { int count = 0 ; while ( n > 0 ) { count = ( n % 10 == d ) ? count + 1 : count ; n = n / 10 ; } return count ; } public static void Main ( ) { int d = 2 ; int n = 214215421 ; Console . WriteLine ( countOccurrances ( n , d ) ) ; } }
Find number of factors of N when location of its two factors whose product is N is given | C # program to implement the above problem ; Function to find the number of factors ; print the number of factors ; Driver code ; initialize the factors position
using System ; class GFG { static void findFactors ( int a , int b ) { int c ; c = a + b - 1 ; Console . Write ( c ) ; } public static void Main ( String [ ] args ) { int a , b ; a = 13 ; b = 36 ; findFactors ( a , b ) ; } }
21 Matchsticks Problem | C # implementation of the approach ; Function to return the optimal strategy ; Removing matchsticks in blocks of five ; Driver code
using System ; class GFG { static void TwentyoneMatchstick ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i += 1 ) { Console . Write ( 5 - arr [ i ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 4 , 2 , 2 } ; int N = arr . Length ; TwentyoneMatchstick ( arr , N ) ; } }
Find the smallest positive number which can not be represented by given digits | C # program to find the smallest positive number which can not be represented by given digits ; Function to find the smallest positive number which can not be represented by given digits ; Storing the count of 0 digit or store the value at 0 th index ; Calculates the min value in the array starting from 1 st index and also store it index . ; If its value at 0 th index is less than min value than either 10 , 100 , 1000 ... can 't be expressed ; If it value is greater than min value than iterate the loop upto first min value index and simply print it index value . ; Driver code ; Value of N is always 10 as we take digit from 0 to 9 ; Calling function
using System ; class GFG { static void expressDigit ( int [ ] arr , int n ) { int min = 9 , index = 0 , temp = 0 ; temp = arr [ 0 ] ; for ( int i = 1 ; i < 10 ; i ++ ) { if ( arr [ i ] < min ) { min = arr [ i ] ; index = i ; } } if ( temp < min ) { Console . Write ( 1 ) ; for ( int i = 1 ; i <= temp + 1 ; i ++ ) Console . Write ( 0 ) ; } else { for ( int i = 0 ; i < min ; i ++ ) Console . Write ( index ) ; Console . Write ( index ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 2 , 1 , 2 , 1 , 1 , 3 , 1 , 1 , 1 } ; int N = 10 ; expressDigit ( arr , N ) ; } }
Find the average of k digits from the beginning and l digits from the end of the given number | C # implementation of the approach ; Function to return the count of digits in num ; Function to return the sum of first n digits of num ; Remove the unnecessary digits ; Function to return the sum of the last n digits of num ; If the average can 't be calculated without  using the same digit more than once ; Sum of the last l digits of n ; Sum of the first k digits of n ( totalDigits - k ) must be removed from the end of the number to get the remaining k digits from the beginning ; Return the average ; Driver code
using System ; class GFG { public static int countDigits ( int num ) { int cnt = 0 ; while ( num > 0 ) { cnt ++ ; num /= 10 ; } return cnt ; } public static int sumFromStart ( int num , int n , int rem ) { num /= ( ( int ) Math . Pow ( 10 , rem ) ) ; int sum = 0 ; while ( num > 0 ) { sum += ( num % 10 ) ; num /= 10 ; } return sum ; } public static int sumFromEnd ( int num , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += ( num % 10 ) ; num /= 10 ; } return sum ; } public static float getAverage ( int n , int k , int l ) { int totalDigits = countDigits ( n ) ; if ( totalDigits < ( k + l ) ) return - 1 ; int sum1 = sumFromEnd ( n , l ) ; int sum2 = sumFromStart ( n , k , totalDigits - k ) ; return ( ( float ) ( sum1 + sum2 ) / ( float ) ( k + l ) ) ; } public static void Main ( String [ ] args ) { int n = 123456 , k = 2 , l = 3 ; Console . WriteLine ( getAverage ( n , k , l ) ) ; } }
Print N terms of Withoff Sequence | C # program to find Wythoff array ; Function to find the n , k term of Wythoff array ; tau = ( sqrt ( 5 ) + 1 ) / 2 ; Already_stored ; T ( n , - 1 ) = n - 1. ; T ( n , 0 ) = floor ( n * tau ) . ; T ( n , k ) = T ( n , k - 1 ) + T ( n , k - 2 ) for k >= 1. ; Store ; Return the ans ; Function to find first n terms of Wythoff array by traversing in anti - diagonal ; Map to store the Wythoff array ; Anti diagonal ; Driver code ; Function call
using System ; using System . Collections . Generic ; class GFG { static int Wythoff ( Dictionary < int , Dictionary < int , int > > mp , int n , int k ) { double tau = ( Math . Sqrt ( 5 ) + 1 ) / 2.0 , t_n_k ; if ( mp . ContainsKey ( n ) && mp [ n ] . ContainsKey ( k ) && mp [ n ] [ k ] != 0 ) return mp [ n ] [ k ] ; if ( k == - 1 ) { return n - 1 ; } else if ( k == 0 ) { t_n_k = Math . Floor ( n * tau ) ; } else { t_n_k = Wythoff ( mp , n , k - 1 ) + Wythoff ( mp , n , k - 2 ) ; } if ( ! mp . ContainsKey ( n ) ) { mp [ n ] = new Dictionary < int , int > ( ) ; } mp [ n ] [ k ] = ( int ) t_n_k ; return ( int ) t_n_k ; } static void Wythoff_Array ( int n ) { int i = 0 , j = 0 , count = 0 ; Dictionary < int , Dictionary < int , int > > mp = new Dictionary < int , Dictionary < int , int > > ( ) ; while ( count < n ) { Console . Write ( Wythoff ( mp , i + 1 , j + 1 ) ) ; count ++ ; if ( count != n ) Console . Write ( " , ▁ " ) ; i ++ ; j -- ; if ( j < 0 ) { j = i ; i = 0 ; } } } static void Main ( ) { int n = 15 ; Wythoff_Array ( n ) ; } }
Sum of two numbers if the original ratio and new ratio obtained by adding a given number to each number is given | C # implementation of the above approach ; Function to return the sum of numbers which are in the ration a : b and after adding x to both the numbers the new ratio becomes c : d ; Driver code
using System ; class GFG { static double sum ( double a , double b , double c , double d , double x ) { double ans = ( x * ( a + b ) * ( c - d ) ) / ( ( a * d ) - ( b * c ) ) ; return ans ; } public static void Main ( ) { double a = 1 , b = 2 , c = 9 , d = 13 , x = 5 ; Console . WriteLine ( sum ( a , b , c , d , x ) ) ; } }
Triangle of numbers arising from Gilbreath 's conjecture | C # code for printing the Triangle of numbers arising from Gilbreath 's conjecture ; Check whether the number is prime or not ; Set the 0 th row of the matrix with c primes from 0 , 0 to 0 , c - 1 ; Find the n , k term of matrix of Gilbreath 's conjecture ; recursively find ; store the ans ; Print first n terms of Gilbreath sequence successive absolute differences of primes read by antidiagonals upwards . ; map to store the matrix and hash to check if the element is present or not ; set the primes of first row ; print the Gilbreath number ; increase the count ; anti diagonal upwards ; Driver code
using System ; using System . Collections . Generic ; class GFG { static bool is_Prime ( int n ) { if ( n < 2 ) return false ; for ( int i = 2 ; i <= Math . Sqrt ( n ) ; i ++ ) if ( n % i == 0 ) return false ; return true ; } static void set_primes ( Dictionary < int , Dictionary < int , int > > mp , Dictionary < int , Dictionary < int , int > > hash , int c ) { int count = 0 ; for ( int i = 2 ; count < c ; i ++ ) { if ( is_Prime ( i ) ) { if ( ! mp . ContainsKey ( 0 ) ) { mp [ 0 ] = new Dictionary < int , int > ( ) ; } if ( ! mp [ 0 ] . ContainsKey ( count ) ) { mp [ 0 ] . Add ( count , i ) ; } else { mp [ 0 ] [ count ] = i ; } count ++ ; if ( ! hash . ContainsKey ( 0 ) ) { hash [ 0 ] = new Dictionary < int , int > ( ) ; } if ( ! hash [ 0 ] . ContainsKey ( count - 1 ) ) { hash [ 0 ] . Add ( count - 1 , 1 ) ; } else { hash [ 0 ] [ count - 1 ] = 1 ; } } } } static int Gilbreath ( Dictionary < int , Dictionary < int , int > > mp , Dictionary < int , Dictionary < int , int > > hash , int n , int k ) { if ( hash . ContainsKey ( n ) && hash [ n ] . ContainsKey ( k ) && hash [ n ] [ k ] != 0 ) return mp [ n ] [ k ] ; int ans = Math . Abs ( Gilbreath ( mp , hash , n - 1 , k + 1 ) - Gilbreath ( mp , hash , n - 1 , k ) ) ; if ( ! mp . ContainsKey ( n ) ) { mp [ n ] = new Dictionary < int , int > ( ) ; } mp [ n ] [ k ] = ans ; return ans ; } static void solve ( int n ) { int i = 0 , j = 0 , count = 0 ; Dictionary < int , Dictionary < int , int > > mp = new Dictionary < int , Dictionary < int , int > > ( ) ; Dictionary < int , Dictionary < int , int > > hash = new Dictionary < int , Dictionary < int , int > > ( ) ; set_primes ( mp , hash , 100 ) ; while ( count < n ) { Console . Write ( Gilbreath ( mp , hash , i , j ) + " , ▁ " ) ; count ++ ; i -- ; j ++ ; if ( i < 0 ) { i = j ; j = 0 ; } } } static void Main ( ) { int n = 15 ; solve ( n ) ; } }
Roots of the quadratic equation when a + b + c = 0 without using Shridharacharya formula | C # implementation of the approach ; Function to print the roots of the quadratic equation when a + b + c = 0 ; Driver code
using System ; class GFG { static void printRoots ( long a , long b , long c ) { Console . WriteLine ( "1 , ▁ " + c / ( a * 1.0 ) ) ; } public static void Main ( ) { long a = 2 ; long b = 3 ; long c = - 5 ; printRoots ( a , b , c ) ; } }
Longest alternative parity subsequence | C # program to find the length of the longest alternative parity subsequence ; Function to find the longest ; Marks the starting of odd number as sequence and alternatively changes ; Finding the longest odd / even sequence ; Find odd number ; Find even number ; Length of the longest even / odd sequence ; Find odd number ; Find even number ; Answer is maximum of both odd / even or even / odd subsequence ; Driver Code
using System ; class GFG { static int longestAlternativeSequence ( int [ ] a , int n ) { int maxi1 = 0 ; int f1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( f1 != 0 ) { if ( a [ i ] % 2 == 0 ) { f1 = 1 ; maxi1 ++ ; } } else { if ( a [ i ] % 2 == 0 ) { maxi1 ++ ; f1 = 0 ; } } } int maxi2 = 0 ; int f2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( f2 == 0 ) { if ( a [ i ] % 2 == 0 ) { f2 = 1 ; maxi2 ++ ; } } else { if ( a [ i ] % 2 == 0 ) { maxi2 ++ ; f2 = 0 ; } } } return Math . Max ( maxi1 , maxi2 ) ; } public static void Main ( ) { int [ ] a = { 13 , 16 , 8 , 9 , 32 , 10 } ; int n = a . Length ; Console . Write ( longestAlternativeSequence ( a , n ) ) ; } }
Nambiar Number Generator | C # implementation of the approach . ; Function to return the Nambiar number of the given number ; If there is no digit to choose ; Choose the first digit ; Chosen digit 's parity ; To store the sum of the consecutive digits starting from the chosen digit ; While there are digits to choose ; Update the sum ; If the parity differs ; Return the current sum concatenated with the Numbiar number for the rest of the string ; Driver code
using System ; using System . Collections . Generic ; class GFG { static String nambiarNumber ( String str , int i ) { if ( i >= str . Length ) return " " ; int firstDigit = ( str [ i ] - '0' ) ; int digitParity = firstDigit % 2 ; int sumDigits = 0 ; while ( i < str . Length ) { sumDigits += ( str [ i ] - '0' ) ; int sumParity = sumDigits % 2 ; if ( digitParity != sumParity ) { break ; } i ++ ; } return ( " " + sumDigits + nambiarNumber ( str , i + 1 ) ) ; } public static void Main ( String [ ] args ) { String str = "9880127431" ; Console . WriteLine ( nambiarNumber ( str , 0 ) ) ; } }
Program to find the Depreciation of Value | C # program to find depreciation of the value initial value , rate and time are given ; Function to return the depreciation of value ; Driver code
using System ; class GFG { static float Depreciation ( float v , float r , float t ) { float D = ( float ) ( v * Math . Pow ( ( 1 - r / 100 ) , t ) ) ; return D ; } public static void Main ( ) { float V1 = 200 , R = 10 , T = 2 ; Console . WriteLine ( Depreciation ( V1 , R , T ) ) ; } }
Highly Totient Number | C # program to find highly totient numbers ; Function to find euler totient number ; Consider all prime factors of n and subtract their multiples from result ; Check if p is a prime factor . ; If yes , then update n and result ; If n has a prime factor greater than sqrt ( n ) ( There can be at - most one such prime factor ) ; Function to find first n highly totient numbers ; Count of Highly totient numbers and value of count of phi of previous numbers ; Store all the values of phi ( x ) upto 10 ^ 5 with frequencies ; If count is greater than count of previous element ; Display the number ; Store the value of phi ; Driver code ; Function call
using System ; using System . Collections . Generic ; class GFG { static int phi ( int n ) { for ( int p = 2 ; p * p <= n ; ++ p ) { if ( n % p == 0 ) { while ( n % p == 0 ) n /= p ; result -= result / p ; } } if ( n > 1 ) result -= result / n ; return result ; } static void Highly_Totient ( int n ) { int count = 0 , p_count = - 1 , i ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( i = 1 ; i < 100000 ; i ++ ) { if ( mp . ContainsKey ( phi ( i ) ) ) { mp [ phi ( i ) ] = mp [ phi ( i ) ] + 1 ; } else { mp . Add ( phi ( i ) , 1 ) ; } } i = 1 ; while ( count < n ) { if ( mp . ContainsKey ( i ) && mp [ i ] > p_count ) { Console . Write ( i ) ; if ( count < n - 1 ) Console . Write ( " , ▁ " ) ; p_count = mp [ i ] ; count ++ ; } i ++ ; } } public static void Main ( String [ ] args ) { int n = 20 ; Highly_Totient ( n ) ; } }
Program to find the Speed of train as per speed of sound | C # implementation of the approach ; Function to find the Speed of train ; Driver code ; calling Function
using System ; class GFG { static int speedOfTrain ( float X , float Y ) { float Speed ; Speed = 1188 * ( ( X - Y ) / Y ) ; return ( int ) Speed ; } public static void Main ( ) { float X = 8f , Y = 7.2f ; int result = ( speedOfTrain ( X , Y ) ) ; Console . Write ( result + " ▁ km / hr " ) ; } }
Maximum value of division of two numbers in an Array | C # program to maximum value of division of two numbers in an array ; Function to maximum value of division of two numbers in an array ; Traverse through the array ; Return the required answer ; Driver code
using System ; class GFG { static int Division ( int [ ] a , int n ) { int maxi = int . MinValue , mini = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { maxi = Math . Max ( a [ i ] , maxi ) ; mini = Math . Min ( a [ i ] , mini ) ; } return maxi / mini ; } public static void Main ( String [ ] args ) { int [ ] a = { 3 , 7 , 9 , 3 , 11 } ; int n = a . Length ; Console . WriteLine ( Division ( a , n ) ) ; } }
Card Shuffle Problem | TCS Digital Advanced Coding Question | C # implementation of the approach ; Total cards ; Function to perform the current round ; Create the required empty piles ; Add cards to the piles one by one ; After all the piles have been reversed the new order will be first card of the first pile , second card of the first pile , ... , last pile of the last pile ( from top to bottom ) ; Function to perform all the rounds ; Create the initial list with all the cards ; Perform all the rounds ; Return the nth card ; Driver code ; nth card will be at ( n - 1 ) th index
using System ; using System . Collections . Generic ; class GFG { static int CARDS = 100 ; static void currentRound ( List < int > list , int totalPiles ) { int i ; List < List < int > > piles = new List < List < int > > ( ) ; for ( i = 0 ; i < totalPiles ; i ++ ) piles . Add ( new List < int > ( ) ) ; int j = 0 ; for ( i = 0 ; i < CARDS ; i ++ ) { piles [ j ] . Add ( list [ i ] ) ; j = ( j + 1 ) % totalPiles ; } int pileNo = 0 ; i = 0 ; j = 0 ; while ( i < CARDS ) { list . Insert ( i , piles [ pileNo ] [ j ] ) ; j ++ ; if ( j >= piles [ pileNo ] . Count ) { pileNo ++ ; j = 0 ; } i ++ ; } } static int performRounds ( int [ ] piles , int rounds , int n ) { List < int > list = new List < int > ( ) ; for ( int i = 1 ; i <= CARDS ; i ++ ) list . Add ( i ) ; for ( int i = 0 ; i < rounds ; i ++ ) currentRound ( list , piles [ i ] ) ; return list [ n ] ; } public static void Main ( String [ ] args ) { int [ ] piles = { 2 , 2 } ; int rounds = piles . Length ; int n = 4 ; n -- ; Console . WriteLine ( performRounds ( piles , rounds , n ) ) ; } }
Ramanujan Prime | C # program to find Ramanujan numbers ; FUnction to return a vector of primes ; Create a boolean array " prime [ 0 . . n ] " and initialize all entries it as true . A value in prime [ i ] will finally be false if i is Not a prime , else true . ; If prime [ p ] is not changed , then it is a prime ; Update all multiples of p greater than or equal to the square of it numbers which are multiple of p and are less than p ^ 2 are already been marked . ; Print all prime numbers ; Function to find number of primes less than or equal to x ; Binary search to find out number of primes less than or equal to x ; Function to find the nth ramanujan prime ; For n >= 1 , a ( n ) < 4 * n * log ( 4 n ) ; We start from upperbound and find where pi ( i ) - pi ( i / 2 ) < n the previous number being the nth ramanujan prime ; Function to find first n Ramanujan numbers ; Get the prime numbers ; Driver code
using System ; using System . Collections . Generic ; class GFG { static int MAX = 1000000 ; static List < int > addPrimes ( ) { int n = MAX ; Boolean [ ] prime = new Boolean [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } List < int > ans = new List < int > ( ) ; for ( int p = 2 ; p <= n ; p ++ ) if ( prime [ p ] ) ans . Add ( p ) ; return ans ; } static int pi ( int x , List < int > v ) { int l = 0 , r = v . Count - 1 , m , i = - 1 ; while ( l <= r ) { m = ( l + r ) / 2 ; if ( v [ m ] <= x ) { i = m ; l = m + 1 ; } else { r = m - 1 ; } } return i + 1 ; } static int Ramanujan ( int n , List < int > v ) { int upperbound = ( int ) ( 4 * n * ( Math . Log ( 4 * n ) / Math . Log ( 2 ) ) ) ; for ( int i = upperbound ; ; i -- ) { if ( pi ( i , v ) - pi ( i / 2 , v ) < n ) return 1 + i ; } } static void Ramanujan_Numbers ( int n ) { int c = 1 ; List < int > v = addPrimes ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { Console . Write ( Ramanujan ( i , v ) ) ; if ( i != n ) Console . Write ( " , ▁ " ) ; } } public static void Main ( String [ ] args ) { int n = 10 ; Ramanujan_Numbers ( n ) ; } }
Quadruplet pair with XOR zero in the given Array | C # implementation of the approach ; Function that returns true if the array contains a valid quadruplet pair ; We can always find a valid quadruplet pair for array size greater than MAX ; For smaller size arrays , perform brute force ; Driver code
using System ; class GFG { static int MAX = 130 ; static Boolean validQuadruple ( int [ ] arr , int n ) { if ( n >= MAX ) return true ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) for ( int k = j + 1 ; k < n ; k ++ ) for ( int l = k + 1 ; l < n ; l ++ ) { if ( ( arr [ i ] ^ arr [ j ] ^ arr [ k ] ^ arr [ l ] ) == 0 ) { return true ; } } return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 0 , 2 , 3 , 7 } ; int n = arr . Length ; if ( validQuadruple ( arr , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }
Find the number of words of X vowels and Y consonants that can be formed from M vowels and N consonants | C # program to find the number of words of X vowels and Y consonants can be formed from M vowels and N consonants ; Function to returns factorial of n ; Function to find nCr ; Function to find the number of words of X vowels and Y consonants can be formed from M vowels and N consonants ; Driver code ; Function call
using System ; class GFG { static int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } static int nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } static int NumberOfWays ( int X , int Y , int M , int N ) { return fact ( X + Y ) * nCr ( M , X ) * nCr ( N , Y ) ; } public static void Main ( String [ ] args ) { int X = 2 , Y = 2 , M = 3 , N = 3 ; Console . WriteLine ( NumberOfWays ( X , Y , M , N ) ) ; } }
Program for sum of cosh ( x ) series upto Nth term | C # program for the sum of cosh ( x ) series ; function to return the factorial of a number ; function to return the sum of the series ; Driver code
using System ; class GFG { static int fact ( int n ) { int i = 1 , fac = 1 ; for ( i = 1 ; i <= n ; i ++ ) fac = fac * i ; return fac ; } static double log_Expansion ( double x , int n ) { double sum = 0 ; int i = 0 ; for ( i = 0 ; i < n ; i ++ ) { sum = sum + Math . Pow ( x , 2 * i ) / fact ( 2 * i ) ; } return sum ; } public static void Main ( String [ ] args ) { double x = 1 ; int n = 10 ; Console . WriteLine ( log_Expansion ( x , n ) ) ; } }