dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int Modulo ( int a , char [ ] b ) { int mod = 0 ; for ( int i = 0 ; i < b . Length ; i ++ ) mod = ( mod * 10 + b [ i ] - '0' ) % a ; return mod ; } static int LastDigit ( char [ ] a , char [ ] b ) { int len_a = a . Length , len_b = b . Length ; if ( len_a == 1 && len_b == 1 && b [ 0 ] == '0' && a [ 0 ] == '0' ) return 1 ; if ( len_b == 1 && b [ 0 ] == '0' ) return 1 ; if ( len_a == 1 && a [ 0 ] == '0' ) return 0 ; int exp = ( Modulo ( 4 , b ) == 0 ) ? 4 : Modulo ( 4 , b ) ; int res = ( int ) ( Math . Pow ( a [ len_a - 1 ] - '0' , exp ) ) ; return res % 10 ; } public static void Main ( ) { char [ ] a = "117" . ToCharArray ( ) , b = { '3' } ; Console . Write ( LastDigit ( a , b ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long reversDigits ( long num ) { long rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static bool isPalindrome ( long num ) { return ( reversDigits ( num ) == num ) ; } static void ReverseandAdd ( long num ) { long rev_num = 0 ; while ( num <= 4294967295 ) { rev_num = reversDigits ( num ) ; num = num + rev_num ; if ( isPalindrome ( num ) ) { Console . WriteLine ( num ) ; break ; } else if ( num > 4294967295 ) { Console . WriteLine ( " No ▁ palindrome ▁ exist " ) ; } } } public static void Main ( ) { ReverseandAdd ( 195 ) ; ReverseandAdd ( 265 ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( a == b ) return a ; if ( a == 0 ) return b ; if ( b == 0 ) return a ; if ( ( ~ a & 1 ) == 1 ) { if ( ( b & 1 ) == 1 ) return gcd ( a >> 1 , b ) ; else return gcd ( a >> 1 , b >> 1 ) << 1 ; } if ( ( ~ b & 1 ) == 1 ) return gcd ( a , b >> 1 ) ; if ( a > b ) return gcd ( ( a - b ) >> 1 , b ) ; return gcd ( ( b - a ) >> 1 , a ) ; } public static void Main ( ) { int a = 34 , b = 17 ; Console . Write ( " Gcd ▁ of ▁ given " + " numbers ▁ is ▁ " + gcd ( a , b ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] sum = new int [ 1000005 ] ; static int toInt ( char x ) { return x - '0' ; } static void prepareSum ( String s ) { sum [ 0 ] = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { sum [ i + 1 ] = sum [ i ] + toInt ( s [ i ] ) ; } } static void query ( int l , int r ) { if ( ( sum [ r + 1 ] - sum [ l ] ) % 3 == 0 ) { Console . WriteLine ( " Divisible ▁ by ▁ 3" ) ; } else { Console . WriteLine ( " Not ▁ divisible ▁ by ▁ 3" ) ; } } public static void Main ( ) { String n = "12468236544" ; prepareSum ( n ) ; query ( 0 , 1 ) ; query ( 1 , 2 ) ; query ( 3 , 6 ) ; query ( 0 , 10 ) ; } }

Index/key variables: i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool oneDigit ( int num ) { return ( num >= 0 && num < 10 ) ; } static bool isPalUtil ( int num , int dupNum ) { if ( oneDigit ( num ) ) return ( num == ( dupNum ) % 10 ) ; if ( ! isPalUtil ( num / 10 , dupNum ) ) return false ; dupNum /= 10 ; return ( num % 10 == ( dupNum ) % 10 ) ; } static bool isPal ( int num ) { if ( num < 0 ) num = - num ; return isPalUtil ( num , dupNum ) ; } static void printPalPrimesLessThanN ( int n ) { bool [ ] prime = new bool [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= n ; i += p ) { prime [ i ] = false ; } } } for ( int p = 2 ; p <= n ; p ++ ) { if ( prime [ p ] && isPal ( p ) ) { Console . Write ( p + " ▁ " ) ; } } } public static void Main ( ) { int n = 100 ; Console . Write ( " Palindromic ▁ primes ▁ smaller ▁ than ▁ or ▁ " + " equal ▁ to ▁ are ▁ : STRNEWLINE " , n ) ; printPalPrimesLessThanN ( n ) ; } }

Index/key variables: i, p
Accumulator variables: dupNum, i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPrimeFactors ( int n ) { int count = 0 ; while ( n % 2 == 0 ) { n = n / 2 ; count ++ ; } for ( int i = 3 ; i <= Math . Sqrt ( n ) ; i = i + 2 ) { while ( n % i == 0 ) { n = n / i ; count ++ ; } } if ( n > 2 ) count ++ ; return ( count ) ; } static void printKAlmostPrimes ( int k , int n ) { for ( int i = 1 , num = 2 ; i <= n ; num ++ ) { if ( countPrimeFactors ( num ) == k ) { Console . Write ( num + " ▁ " ) ; i ++ ; } } return ; } public static void Main ( ) { int n = 10 , k = 2 ; Console . WriteLine ( " First ▁ " + n + " ▁ " + k + " - almost ▁ prime ▁ numbers ▁ : ▁ " ) ; printKAlmostPrimes ( k , n ) ; } }

Accumulator variables: count, i, num
Iterator variables: i
Class/struct names: GFG
C# program:
class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static void lowest ( int den3 , int num3 ) { int common_factor = gcd ( num3 , den3 ) ; den3 = den3 / common_factor ; num3 = num3 / common_factor ; System . Console . WriteLine ( num3 + " / " + den3 ) ; } static void addFraction ( int num1 , int den1 , int num2 , int den2 ) { int den3 = gcd ( den1 , den2 ) ; den3 = ( den1 * den2 ) / den3 ; int num3 = ( num1 ) * ( den3 / den1 ) + ( num2 ) * ( den3 / den2 ) ; lowest ( den3 , num3 ) ; } public static void Main ( ) { int num1 = 1 , den1 = 500 , num2 = 2 , den2 = 1500 ; System . Console . Write ( num1 + " / " + den1 + " ▁ + ▁ " + num2 + " / " + den2 + " ▁ is ▁ equal ▁ to ▁ " ) ; addFraction ( num1 , den1 , num2 , den2 ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int findPieces ( int n ) { return ( n * ( n + 1 ) ) / 2 + 1 ; } public static void Main ( ) { Console . WriteLine ( findPieces ( 1 ) ) ; Console . WriteLine ( findPieces ( 2 ) ) ; Console . WriteLine ( findPieces ( 3 ) ) ; Console . Write ( findPieces ( 50 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static double M_E = 2.71828182845904523536 ; public static double M_PI = 3.141592654 ; static long findDigits ( int n ) { if ( n < 0 ) return 0 ; if ( n <= 1 ) return 1 ; double x = ( n * Math . Log10 ( n / M_E ) + Math . Log10 ( 2 * M_PI * n ) / 2.0 ) ; return ( long ) Math . Floor ( x ) + 1 ; } public static void Main ( ) { Console . WriteLine ( findDigits ( 1 ) ) ; Console . WriteLine ( findDigits ( 50000000 ) ) ; Console . WriteLine ( findDigits ( 1000000000 ) ) ; Console . Write ( findDigits ( 120 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int findDigits ( int n ) { if ( n < 0 ) return 0 ; if ( n <= 1 ) return 1 ; double digits = 0 ; for ( int i = 2 ; i <= n ; i ++ ) digits += Math . Log10 ( i ) ; return ( int ) Math . Floor ( digits ) + 1 ; } public static void Main ( ) { Console . Write ( findDigits ( 1 ) + " STRNEWLINE " ) ; Console . Write ( findDigits ( 5 ) + " STRNEWLINE " ) ; Console . Write ( findDigits ( 10 ) + " STRNEWLINE " ) ; Console . Write ( findDigits ( 120 ) + " STRNEWLINE " ) ; } }

Accumulator variables: digits, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countEvenSum ( int [ ] arr , int n ) { int result = 0 ; for ( int i = 0 ; i <= n - 1 ; i ++ ) { int sum = 0 ; for ( int j = i ; j <= n - 1 ; j ++ ) { sum = sum + arr [ j ] ; if ( sum % 2 == 0 ) result ++ ; } } return ( result ) ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 2 , 3 , 4 , 1 } ; int n = arr . Length ; Console . Write ( " The ▁ Number ▁ of ▁ Subarrays " + " ▁ with ▁ even ▁ sum ▁ is ▁ " ) ; Console . WriteLine ( countEvenSum ( arr , n ) ) ; } }

Index/key variables: j
Accumulator variables: i, j, result
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countEvenSum ( int [ ] arr , int n ) { int [ ] temp = { 1 , 0 } ; int result = 0 , sum = 0 ; for ( int i = 0 ; i <= n - 1 ; i ++ ) { sum = ( ( sum + arr [ i ] ) % 2 + 2 ) % 2 ; temp [ sum ] ++ ; } result = result + ( temp [ 0 ] * ( temp [ 0 ] - 1 ) / 2 ) ; result = result + ( temp [ 1 ] * ( temp [ 1 ] - 1 ) / 2 ) ; return ( result ) ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 2 , 3 , 4 , 1 } ; int n = arr . Length ; Console . WriteLine ( " The ▁ Number ▁ of ▁ Subarrays " + " ▁ with ▁ even ▁ sum ▁ is ▁ " + countEvenSum ( arr , n ) ) ; } }

Index/key variables: i, sum
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int calculateSum ( int n ) { if ( n <= 0 ) return 0 ; int [ ] fibo = new int [ n + 1 ] ; fibo [ 0 ] = 0 ; fibo [ 1 ] = 1 ; int sum = fibo [ 0 ] + fibo [ 1 ] ; for ( int i = 2 ; i <= n ; i ++ ) { fibo [ i ] = fibo [ i - 1 ] + fibo [ i - 2 ] ; sum += fibo [ i ] ; } return sum ; } static void Main ( ) { int n = 4 ; Console . WriteLine ( " Sum ▁ of ▁ Fibonacci " + " ▁ numbers ▁ is ▁ : ▁ " + calculateSum ( n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1000 ; static int [ ] f = new int [ MAX ] ; static int fib ( int n ) { for ( int i = 0 ; i < MAX ; i ++ ) f [ i ] = 0 ; if ( n == 0 ) return 0 ; if ( n == 1 n == 2 ) return ( f [ n ] = 1 ) ; if ( f [ n ] == 1 ) return f [ n ] ; int k ; if ( ( n & 1 ) == 1 ) k = ( n + 1 ) / 2 ; else k = n / 2 ; if ( ( n & 1 ) == 1 ) f [ n ] = ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) ; else f [ n ] = ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) ; return f [ n ] ; } static int calculateSum ( int n ) { return fib ( n + 2 ) - 1 ; } public static void Main ( ) { int n = 4 ; Console . Write ( " Sum ▁ of ▁ Fibonacci ▁ numbers ▁ is ▁ : ▁ " + calculateSum ( n ) ) ; } }

Index/key variables: MAX, i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findCombinationsUtil ( int [ ] arr , int index , int num , int reducedNum ) { if ( reducedNum < 0 ) return ; if ( reducedNum == 0 ) { for ( int i = 0 ; i < index ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; return ; } int prev = ( index == 0 ) ? 1 : arr [ index - 1 ] ; for ( int k = prev ; k <= num ; k ++ ) { arr [ index ] = k ; findCombinationsUtil ( arr , index + 1 , num , reducedNum - k ) ; } } static void findCombinations ( int n ) { int [ ] arr = new int [ n ] ; findCombinationsUtil ( arr , 0 , n , n ) ; } static public void Main ( ) { int n = 5 ; findCombinations ( n ) ; } }

Index/key variables: i, index, n
Accumulator variables: i, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int z = 0 ; static int pow1 ( int base1 , int exponent , int modulus ) { int result = 1 ; base1 = base1 % modulus ; while ( exponent > 0 ) { if ( exponent % 2 == 1 ) result = ( result * base1 ) % modulus ; exponent = exponent >> 1 ; base1 = ( base1 * base1 ) % modulus ; } return result ; } static int gcd ( int a , int b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } static int order ( int p , int b ) { if ( gcd ( p , b ) != 1 ) { Console . WriteLine ( " p ▁ and ▁ b ▁ are " + " not ▁ co - prime . " ) ; return - 1 ; } int k = 3 ; while ( true ) { if ( pow1 ( b , k , p ) == 1 ) return k ; k ++ ; } } static int convertx2e ( int x ) { z = 0 ; while ( x % 2 == 0 ) { x /= 2 ; z ++ ; } return x ; } static int STonelli ( int n , int p ) { if ( gcd ( n , p ) != 1 ) { Console . WriteLine ( " a ▁ and ▁ p ▁ are ▁ not ▁ coprime " ) ; return - 1 ; } if ( pow1 ( n , ( p - 1 ) / 2 , p ) == ( p - 1 ) ) { Console . WriteLine ( " no ▁ sqrt ▁ possible " ) ; return - 1 ; } int s , e ; s = convertx2e ( p - 1 ) ; e = z ; int q ; for ( q = 2 ; ; q ++ ) { if ( pow1 ( q , ( p - 1 ) / 2 , p ) == ( p - 1 ) ) break ; } int x = pow1 ( n , ( s + 1 ) / 2 , p ) ; int b = pow1 ( n , s , p ) ; int g = pow1 ( q , s , p ) ; int r = e ; while ( true ) { int m ; for ( m = 0 ; m < r ; m ++ ) { if ( order ( p , b ) == - 1 ) return - 1 ; if ( order ( p , b ) == Math . Pow ( 2 , m ) ) break ; } if ( m == 0 ) return x ; x = ( x * pow1 ( g , ( int ) Math . Pow ( 2 , r - m - 1 ) , p ) ) % p ; g = pow1 ( g , ( int ) Math . Pow ( 2 , r - m ) , p ) ; b = ( b * g ) % p ; if ( b == 1 ) return x ; r = m ; } } static void Main ( ) { int n = 2 ; int p = 113 ; int x = STonelli ( n , p ) ; if ( x == - 1 ) Console . WriteLine ( " Modular ▁ square ▁ root " + " is ▁ not ▁ exist STRNEWLINE " ) ; else Console . WriteLine ( " Modular ▁ square ▁ root ▁ of " + " { 0 } ▁ and ▁ { 1 } ▁ is ▁ { 2 } STRNEWLINE " , n , p , x ) ; } }

Accumulator variables: k, m, q, x, z
Iterator variables: m, q
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPower ( int x , int y ) { int res1 = ( int ) Math . Log ( y ) / ( int ) Math . Log ( x ) ; double res2 = Math . Log ( y ) / Math . Log ( x ) ; return ( res1 == res2 ) ; } static void Main ( ) { if ( isPower ( 27 , 729 ) ) Console . WriteLine ( "1" ) ; else Console . WriteLine ( "0" ) ; } }

Class/struct names: GFG
C# program:
using System ; class Quadratic { void findRoots ( int a , int b , int c ) { if ( a == 0 ) { Console . Write ( " Invalid " ) ; return ; } int d = b * b - 4 * a * c ; double sqrt_val = Math . Abs ( d ) ; if ( d > 0 ) { Console . Write ( " Roots ▁ are ▁ real ▁ and ▁ different ▁ STRNEWLINE " ) ; Console . Write ( ( double ) ( - b + sqrt_val ) / ( 2 * a ) + " STRNEWLINE " + ( double ) ( - b - sqrt_val ) / ( 2 * a ) ) ; } else { Console . Write ( " Roots ▁ are ▁ complex ▁ STRNEWLINE " ) ; Console . Write ( - ( double ) b / ( 2 * a ) + " ▁ + ▁ i " + sqrt_val + " STRNEWLINE " + - ( double ) b / ( 2 * a ) + " ▁ - ▁ i " + sqrt_val ) ; } } public static void Main ( ) { Quadratic obj = new Quadratic ( ) ; int a = 1 , b = - 7 , c = 12 ; obj . findRoots ( a , b , c ) ; } }

Class/struct names: Quadratic
C# program:
using System ; public class GFG { static bool isPerfectSquare ( int n ) { for ( int sum = 0 , i = 1 ; sum < n ; i += 2 ) { sum += i ; if ( sum == n ) return true ; } return false ; } public static void Main ( String [ ] args ) { if ( isPerfectSquare ( 35 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; if ( isPerfectSquare ( 49 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Accumulator variables: i, sum
Iterator variables: sum
Class/struct names: GFG
C# program:
using System ; class GFG { static int findCount ( int d ) { return 9 * ( ( int ) ( Math . Pow ( 10 , d - 1 ) ) - ( int ) ( Math . Pow ( 9 , d - 1 ) ) ) ; } public static void Main ( ) { int d = 1 ; Console . WriteLine ( findCount ( d ) ) ; d = 2 ; Console . WriteLine ( findCount ( d ) ) ; d = 4 ; Console . WriteLine ( findCount ( d ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int countDyckPaths ( int n ) { int res = 1 ; for ( int i = 0 ; i < n ; ++ i ) { res *= ( 2 * n - i ) ; res /= ( i + 1 ) ; } return res / ( n + 1 ) ; } public static void Main ( ) { int n = 4 ; Console . WriteLine ( " Number ▁ of ▁ " + " Dyck ▁ Paths ▁ is ▁ " + countDyckPaths ( n ) ) ; } }

Accumulator variables: res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isTriangular ( int num ) { if ( num < 0 ) return false ; int sum = 0 ; for ( int n = 1 ; sum <= num ; n ++ ) { sum = sum + n ; if ( sum == num ) return true ; } return false ; } public static void Main ( ) { int n = 55 ; if ( isTriangular ( n ) ) Console . WriteLine ( " The ▁ number ▁ " + " is ▁ a ▁ triangular ▁ number " ) ; else Console . WriteLine ( " The ▁ number " + " ▁ is ▁ NOT ▁ a ▁ triangular ▁ number " ) ; } }

Accumulator variables: n
Iterator variables: n
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isTriangular ( int num ) { if ( num < 0 ) return false ; int c = ( - 2 * num ) ; int b = 1 , a = 1 ; int d = ( b * b ) - ( 4 * a * c ) ; if ( d < 0 ) return false ; float root1 = ( - b + ( float ) Math . Sqrt ( d ) ) / ( 2 * a ) ; float root2 = ( - b - ( float ) Math . Sqrt ( d ) ) / ( 2 * a ) ; if ( root1 > 0 && Math . Floor ( root1 ) == root1 ) return true ; if ( root2 > 0 && Math . Floor ( root2 ) == root2 ) return true ; return false ; } public static void Main ( ) { int num = 55 ; if ( isTriangular ( num ) ) Console . WriteLine ( " The ▁ number ▁ is ▁ a ▁ " + " triangular ▁ number " ) ; else Console . WriteLine ( " The ▁ number ▁ is ▁ NOT ▁ " + " a ▁ triangular ▁ number " ) ; } }

Class/struct names: GFG
C# program:
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 b_ase ) { int len = str . Length ; int power = 1 ; int num = 0 ; int i ; for ( i = len - 1 ; i >= 0 ; i -- ) { if ( val ( str [ i ] ) >= b_ase ) { Console . WriteLine ( " Invalid ▁ Number " ) ; return - 1 ; } num += val ( str [ i ] ) * power ; power = power * b_ase ; } return num ; } public static void Main ( ) { string str = "11A " ; int b_ase = 16 ; Console . WriteLine ( " Decimal ▁ equivalent ▁ of ▁ " + str + " ▁ in ▁ base ▁ " + b_ase + " ▁ is ▁ " + toDeci ( str , b_ase ) ) ; } }

Index/key variables: i
Accumulator variables: i, num
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { int c ; while ( a != 0 ) { c = a ; a = b % a ; b = c ; } return b ; } static void forbenius ( int X , int Y ) { if ( gcd ( X , Y ) != 1 ) { Console . WriteLine ( " NA " ) ; return ; } int A = ( X * Y ) - ( X + Y ) ; int N = ( X - 1 ) * ( Y - 1 ) / 2 ; Console . WriteLine ( " Largest ▁ Amount ▁ = ▁ " + A ) ; Console . WriteLine ( " Total ▁ Count ▁ = ▁ " + N ) ; } public static void Main ( ) { int X = 2 , Y = 5 ; forbenius ( X , Y ) ; X = 5 ; Y = 10 ; Console . WriteLine ( ) ; forbenius ( X , Y ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static char xor_c ( char a , char b ) { return ( a == b ) ? '0' : '1' ; } static char flip ( char c ) { return ( c == '0' ) ? '1' : '0' ; } static String binarytoGray ( String binary ) { String gray = " " ; gray += binary [ 0 ] ; for ( int i = 1 ; i < binary . Length ; i ++ ) { gray += xor_c ( binary [ i - 1 ] , binary [ i ] ) ; } return gray ; } static String graytoBinary ( String gray ) { String binary = " " ; binary += gray [ 0 ] ; for ( int i = 1 ; i < gray . Length ; i ++ ) { if ( gray [ i ] == '0' ) binary += binary [ i - 1 ] ; else binary += flip ( binary [ i - 1 ] ) ; } return binary ; } public static void Main ( ) { String binary = "01001" ; Console . WriteLine ( " Gray ▁ code ▁ of ▁ " + binary + " ▁ is ▁ " + binarytoGray ( binary ) ) ; String gray = "01101" ; Console . Write ( " Binary ▁ code ▁ of ▁ " + gray + " ▁ is ▁ " + graytoBinary ( gray ) ) ; } }

Index/key variables: i
Accumulator variables: binary, gray, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int seriesSum ( int calculated , int current , int N ) { int i , cur = 1 ; if ( current == N + 1 ) return 0 ; for ( i = calculated ; i < calculated + current ; i ++ ) cur *= i ; return cur + seriesSum ( i , current + 1 , N ) ; } public static void Main ( ) { int N = 5 ; Console . WriteLine ( seriesSum ( 1 , 1 , N ) ) ; } }

Accumulator variables: cur, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getSum ( int [ ] BITree , int index ) { int sum = 0 ; while ( index > 0 ) { sum += BITree [ index ] ; index -= index & ( - index ) ; } return sum ; } static void updateBIT ( int [ ] BITree , int n , int index , int val ) { while ( index <= n ) { BITree [ index ] += val ; index += index & ( - index ) ; } } static void convert ( int [ ] arr , int n ) { int [ ] temp = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) temp [ i ] = arr [ i ] ; Array . Sort ( temp ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = lower_bound ( temp , 0 , n , arr [ i ] ) + 1 ; } } static int lower_bound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( element > a [ middle ] ) low = middle + 1 ; else high = middle ; } return low ; } static int getInvCount ( int [ ] arr , int n ) { int invcount = 0 ; convert ( arr , n ) ; int [ ] BIT = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) BIT [ i ] = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { invcount += getSum ( BIT , arr [ i ] - 1 ) ; updateBIT ( BIT , n , arr [ i ] , 1 ) ; } return invcount ; } public static void Main ( String [ ] args ) { int [ ] arr = { 8 , 4 , 2 , 1 } ; int n = arr . Length ; Console . Write ( " Number ▁ of ▁ inversions ▁ are ▁ : ▁ " + getInvCount ( arr , n ) ) ; } }

Index/key variables: i, index, middle, n
Accumulator variables: i, index, invcount, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int modFact ( int n , int p ) { if ( n >= p ) return 0 ; int result = 1 ; for ( int i = 1 ; i <= n ; i ++ ) result = ( result * i ) % p ; return result ; } static void Main ( ) { int n = 25 , p = 29 ; Console . Write ( modFact ( n , p ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int inv ( int a , int m ) { int m0 = m , t , q ; int x0 = 0 , x1 = 1 ; if ( m == 1 ) return 0 ; while ( a > 1 ) { q = a / m ; t = m ; m = a % m ; a = t ; t = x0 ; x0 = x1 - q * x0 ; x1 = t ; } if ( x1 < 0 ) x1 += m0 ; return x1 ; } static int findMinX ( int [ ] num , int [ ] rem , int k ) { int prod = 1 ; for ( int i = 0 ; i < k ; i ++ ) prod *= num [ i ] ; int result = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int pp = prod / num [ i ] ; result += rem [ i ] * inv ( pp , num [ i ] ) * pp ; } return result % prod ; } static public void Main ( ) { int [ ] num = { 3 , 4 , 5 } ; int [ ] rem = { 2 , 3 , 1 } ; int k = num . Length ; Console . WriteLine ( " x ▁ is ▁ " + findMinX ( num , rem , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, prod, result, x1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinX ( int [ ] num , int [ ] rem , int k ) { int x = 1 ; while ( true ) { int j ; for ( j = 0 ; j < k ; j ++ ) if ( x % num [ j ] != rem [ j ] ) break ; if ( j == k ) return x ; x ++ ; } } public static void Main ( ) { int [ ] num = { 3 , 4 , 5 } ; int [ ] rem = { 2 , 3 , 1 } ; int k = num . Length ; Console . WriteLine ( " x ▁ is ▁ " + findMinX ( num , rem , k ) ) ; } }

Index/key variables: j
Accumulator variables: j, x
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; class GFG { static int nCrModpDP ( int n , int r , int p ) { int [ ] C = new int [ r + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = Math . Min ( i , r ) ; j > 0 ; j -- ) C [ j ] = ( C [ j ] + C [ j - 1 ] ) % p ; } return C [ r ] ; } static int nCrModpLucas ( int n , int r , int p ) { if ( r == 0 ) return 1 ; int ni = n % p ; int ri = r % p ; } public static void Main ( ) { int n = 1000 , r = 900 , p = 13 ; Console . Write ( " Value ▁ of ▁ nCr ▁ % ▁ p ▁ is ▁ " + nCrModpLucas ( n , r , p ) ) ; } }

Index/key variables: j, r
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int N = 30 ; public static int [ ] fib = new int [ N ] ; public static int largestFiboLessOrEqual ( int n ) { fib [ 0 ] = 1 ; fib [ 1 ] = 2 ; int i ; for ( i = 2 ; fib [ i - 1 ] <= n ; i ++ ) { fib [ i ] = fib [ i - 1 ] + fib [ i - 2 ] ; } return ( i - 2 ) ; } public static String fibonacciEncoding ( int n ) { int index = largestFiboLessOrEqual ( n ) ; char [ ] codeword = new char [ index + 3 ] ; int i = index ; while ( n > 0 ) { codeword [ i ] = '1' ; n = n - fib [ i ] ; i = i - 1 ; while ( i >= 0 && fib [ i ] > n ) { codeword [ i ] = '0' ; i = i - 1 ; } } codeword [ index + 1 ] = '1' ; codeword [ index + 2 ] = ' \0' ; string str = new string ( codeword ) ; return str ; } static public void Main ( ) { int n = 143 ; Console . WriteLine ( " Fibonacci ▁ code ▁ word ▁ for ▁ " + n + " ▁ is ▁ " + fibonacciEncoding ( n ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG