dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static bool SieveOfEratosthenes ( int n , bool [ ] isPrime ) { isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( int i = 2 ; i <= n ; i ++ ) isPrime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( isPrime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) isPrime [ i ] = false ; } } return false ; } static void findPrimePair ( int n ) { bool [ ] isPrime = new bool [ n + 1 ] ; SieveOfEratosthenes ( n , isPrime ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPrime [ i ] && isPrime [ n - i ] ) { Console . Write ( i + " ▁ " + ( n - i ) ) ; return ; } } } public static void Main ( ) { int n = 74 ; findPrimePair ( n ) ; } }

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { public static int getFirstDigit ( int x ) { while ( x >= 10 ) x /= 10 ; return x ; } public static int getCountWithSameStartAndEndFrom1 ( int x ) { if ( x < 10 ) return x ; int tens = x / 10 ; int res = tens + 9 ; int firstDigit = getFirstDigit ( x ) ; int lastDigit = x % 10 ; if ( lastDigit < firstDigit ) res -- ; return res ; } public static int getCountWithSameStartAndEnd ( int start , int end ) { return getCountWithSameStartAndEndFrom1 ( end ) - getCountWithSameStartAndEndFrom1 ( start - 1 ) ; } public static void Main ( ) { int start = 5 , end = 40 ; Console . Write ( getCountWithSameStartAndEnd ( start , end ) ) ; } }

Accumulator variables: res, x
Class/struct names: GFG
C# program:
using System ; class GFG { static void sieveOfEratosthenes ( int n , bool [ ] isPrime ) { isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( int i = 2 ; i <= n ; i ++ ) isPrime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( isPrime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) isPrime [ i ] = false ; } } } static bool rightTruPrime ( int n ) { bool [ ] isPrime = new bool [ n + 1 ] ; sieveOfEratosthenes ( n , isPrime ) ; while ( n != 0 ) { if ( isPrime [ n ] ) n = n / 10 ; else return false ; } return true ; } public static void Main ( ) { int n = 59399 ; if ( rightTruPrime ( n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, n, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static void SieveOfEratosthenes ( int n , bool [ ] prime ) { for ( int i = 0 ; i <= n ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } } static void mersennePrimes ( int n ) { bool [ ] prime = new bool [ n + 1 ] ; SieveOfEratosthenes ( n , prime ) ; for ( int k = 2 ; ( ( 1 << k ) - 1 ) <= n ; k ++ ) { long num = ( 1 << k ) - 1 ; if ( prime [ ( int ) ( num ) ] ) Console . Write ( num + " ▁ " ) ; } } public static void Main ( ) { int n = 31 ; Console . WriteLine ( " Mersenne ▁ prime ▁ numbers " + " ▁ smaller ▁ than ▁ or ▁ equal ▁ to ▁ " + n ) ; mersennePrimes ( n ) ; } }

Index/key variables: i, p
Accumulator variables: i, k, p
Iterator variables: i, k, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSum ( int N , int K ) { int ans = 0 ; for ( int i = 1 ; i <= N ; i ++ ) ans += ( i % K ) ; return ans ; } static public void Main ( ) { int N = 10 , K = 2 ; Console . WriteLine ( findSum ( N , K ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSum ( int N , int K ) { int ans = 0 ; int y = N / K ; int x = N % K ; ans = ( K * ( K - 1 ) / 2 ) * y + ( x * ( x + 1 ) ) / 2 ; return ans ; } static public void Main ( ) { int N = 10 , K = 2 ; Console . WriteLine ( findSum ( N , K ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int findnum ( String str ) { int n = str . Length ; int count_after_dot = 0 ; bool dot_seen = false ; int num = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] != ' . ' ) { num = num * 10 + ( str [ i ] - '0' ) ; if ( dot_seen == true ) count_after_dot ++ ; } else dot_seen = true ; } if ( dot_seen == false ) return 1 ; int dem = ( int ) Math . Pow ( 10 , count_after_dot ) ; return ( dem / gcd ( num , dem ) ) ; } public static void Main ( ) { String str = "5.125" ; Console . Write ( findnum ( str ) ) ; } }

Index/key variables: i
Accumulator variables: count_after_dot, i
Iterator variables: i
Boolean variables: dot_seen
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxHandshake ( int n ) { return ( n * ( n - 1 ) ) / 2 ; } public static void Main ( ) { int n = 10 ; Console . Write ( maxHandshake ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool divisible ( string N , int digit ) { int ans = 0 ; for ( int i = 0 ; i < N . Length ; i ++ ) { ans = ( ans * 10 + ( N [ i ] - '0' ) ) ; ans %= digit ; } return ( ans == 0 ) ; } static int allDigits ( string N ) { bool [ ] divide = new bool [ 10 ] ; for ( int i = 0 ; i < divide . Length ; i ++ ) { divide [ i ] = false ; } divide [ 1 ] = true ; for ( int digit = 2 ; digit <= 9 ; digit ++ ) { if ( divisible ( N , digit ) ) divide [ digit ] = true ; } int result = 0 ; for ( int i = 0 ; i < N . Length ; i ++ ) { if ( divide [ N [ i ] - '0' ] == true ) result ++ ; } return result ; } public static void Main ( ) { string N = "122324" ; Console . Write ( allDigits ( N ) ) ; } }

Index/key variables: digit, i
Accumulator variables: digit, i, result
Iterator variables: digit, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int getSum ( int n ) { for ( int i = 1 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { sum = sum + i ; } { sum = sum + i ; sum = sum + ( n / i ) ; } } } return sum - n ; } static void printAliquot ( int n ) { Console . Write ( n + " ▁ " ) ; HashSet < int > s = new HashSet < int > ( ) ; s . Add ( n ) ; while ( n > 0 ) { n = getSum ( n ) ; if ( s . Contains ( n ) ) { Console . Write ( " Repeats with " break ; } Console . Write ( n + " ▁ " ) ; s . Add ( n ) ; } } public static void Main ( String [ ] args ) { printAliquot ( 12 ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int MAX = 10000 ; static ArrayList primes = new ArrayList ( ) ; static void sieveSundaram ( ) { bool [ ] marked = new bool [ MAX / 2 + 1 ] ; Array . Fill ( marked , false ) ; for ( int i = 1 ; i <= ( Math . Sqrt ( MAX ) - 1 ) / 2 ; i ++ ) for ( int j = ( i * ( i + 1 ) ) << 1 ; j <= MAX / 2 ; j = j + 2 * i + 1 ) marked [ j ] = true ; primes . Add ( 2 ) ; for ( int i = 1 ; i <= MAX / 2 ; i ++ ) if ( marked [ i ] == false ) primes . Add ( 2 * i + 1 ) ; } static int LSCPUtil ( int limit , long [ ] sum_prime ) { int max_length = - 1 ; int prime_number = - 1 ; for ( int i = 0 ; ( int ) primes [ i ] <= limit ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( sum_prime [ i ] - sum_prime [ j ] > limit ) break ; long consSum = sum_prime [ i ] - sum_prime [ j ] ; int [ ] prime = ( int [ ] ) primes . ToArray ( typeof ( int ) ) ; if ( Array . BinarySearch ( prime , ( int ) consSum ) >= 0 ) { if ( max_length < i - j + 1 ) { max_length = i - j + 1 ; prime_number = ( int ) consSum ; } } } } return prime_number ; } static void LSCP ( int [ ] arr , int n ) { sieveSundaram ( ) ; long [ ] sum_prime = new long [ primes . Count + 1 ] ; sum_prime [ 0 ] = 0 ; for ( int i = 1 ; i <= primes . Count ; i ++ ) sum_prime [ i ] = ( int ) primes [ i - 1 ] + sum_prime [ i - 1 ] ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( LSCPUtil ( arr [ i ] , sum_prime ) + " ▁ " ) ; } public static void Main ( string [ ] arg ) { int [ ] arr = { 10 , 30 , 40 , 50 , 1000 } ; int n = arr . Length ; LSCP ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countNums ( int n , int x , int y ) { bool [ ] arr = new bool [ n + 1 ] ; if ( x <= n ) arr [ x ] = true ; if ( y <= n ) arr [ y ] = true ; int result = 0 ; for ( int i = Math . Min ( x , y ) ; i <= n ; i ++ ) { if ( arr [ i ] ) { if ( i + x <= n ) arr [ i + x ] = true ; if ( i + y <= n ) arr [ i + y ] = true ; result ++ ; } } return result ; } static public void Main ( ) { int n = 15 , x = 5 , y = 7 ; Console . WriteLine ( countNums ( n , x , y ) ) ; } }

Index/key variables: i, x, y
Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int reverse ( int x ) { int rev = 0 ; while ( x > 0 ) { rev = ( rev * 10 ) + x % 10 ; x = x / 10 ; } return rev ; } static void printEmirp ( 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 ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } for ( int p = 2 ; p <= n ; p ++ ) { if ( prime [ p ] ) { int rev = reverse ( p ) ; if ( p != rev && rev <= n && prime [ rev ] ) { Console . Write ( p + " ▁ " + rev + " ▁ " ) ; prime [ rev ] = false ; } } } } public static void Main ( ) { int n = 100 ; printEmirp ( n ) ; } }

Index/key variables: i, p, rev
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int getSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= ( Math . Sqrt ( n ) ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) sum = sum + i ; { sum = sum + i ; sum = sum + ( n / i ) ; } } } sum = sum - n ; return sum ; } static bool checkAbundant ( int n ) { return ( getSum ( n ) > n ) ; } public static void Main ( ) { if ( checkAbundant ( 12 ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; if ( checkAbundant ( 15 ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPowerful ( int n ) { while ( n % 2 == 0 ) { int power = 0 ; while ( n % 2 == 0 ) { n /= 2 ; power ++ ; } if ( power == 1 ) return false ; } for ( int factor = 3 ; factor <= Math . Sqrt ( n ) ; factor += 2 ) { int power = 0 ; while ( n % factor == 0 ) { n = n / factor ; power ++ ; } if ( power == 1 ) return false ; } return ( n == 1 ) ; } public static void Main ( ) { if ( isPowerful ( 20 ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; if ( isPowerful ( 27 ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

Accumulator variables: factor, n, power
Iterator variables: factor
Class/struct names: GFG
C# program:
using System ; class GFG { static int divisorsSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= ( Math . Sqrt ( n ) ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { sum = sum + i ; } { sum = sum + i ; sum = sum + ( n / i ) ; } } } return sum ; } static bool isDeficient ( int n ) { return ( divisorsSum ( n ) < ( 2 * n ) ) ; } public static void Main ( ) { string var = isDeficient ( 12 ) ? " YES " : " NO " ; Console . WriteLine ( var ) ; string var1 = isDeficient ( 15 ) ? " YES " : " NO " ; Console . WriteLine ( var1 ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class Test { static int MAX = 10000 ; static ArrayList primes = new ArrayList ( 10 ) ; static void sieveSundaram ( ) { bool [ ] marked = new bool [ MAX / 2 + 100 ] ; for ( int i = 1 ; i <= ( Math . Sqrt ( MAX ) - 1 ) / 2 ; i ++ ) for ( int j = ( i * ( i + 1 ) ) << 1 ; j <= MAX / 2 ; j = j + 2 * i + 1 ) marked [ j ] = true ; primes . Add ( 2 ) ; for ( int i = 1 ; i <= MAX / 2 ; i ++ ) if ( marked [ i ] == false ) primes . Add ( 2 * i + 1 ) ; } static bool isSmith ( int n ) { int original_no = n ; int pDigitSum = 0 ; for ( int i = 0 ; ( int ) primes [ i ] <= n / 2 ; i ++ ) { while ( n % ( int ) primes [ i ] == 0 ) { int p = ( int ) primes [ i ] ; n = n / p ; while ( p > 0 ) { pDigitSum += ( p % 10 ) ; p = p / 10 ; } } } if ( n != 1 && n != original_no ) { while ( n > 0 ) { pDigitSum = pDigitSum + n % 10 ; n = n / 10 ; } } int sumDigits = 0 ; while ( original_no > 0 ) { sumDigits = sumDigits + original_no % 10 ; original_no = original_no / 10 ; } return ( pDigitSum == sumDigits ) ; } public static void Main ( ) { sieveSundaram ( ) ; Console . WriteLine ( " Printing ▁ first ▁ few ▁ Smith ▁ Numbers " + " ▁ using ▁ isSmith ( ) " ) ; for ( int i = 1 ; i < 500 ; i ++ ) if ( isSmith ( i ) ) Console . Write ( i + " ▁ " ) ; } }

Index/key variables: i, j
Accumulator variables: i, pDigitSum
Iterator variables: i, j
Class/struct names: Test
C# program:
using System ; class GFG { static bool iskaprekar ( int n ) { if ( n == 1 ) return true ; int sq_n = n * n ; int count_digits = 0 ; while ( sq_n != 0 ) { count_digits ++ ; sq_n /= 10 ; } sq_n = n * n ; for ( int r_digits = 1 ; r_digits < count_digits ; r_digits ++ ) { int eq_parts = ( int ) Math . Pow ( 10 , r_digits ) ; if ( eq_parts == n ) continue ; int sum = sq_n / eq_parts + sq_n % eq_parts ; if ( sum == n ) return true ; } return false ; } public static void Main ( ) { Console . WriteLine ( " Printing ▁ first ▁ few ▁ " + " Kaprekar ▁ Numbers ▁ using ▁ iskaprekar ( ) " ) ; for ( int i = 1 ; i < 10000 ; i ++ ) if ( iskaprekar ( i ) ) Console . Write ( i + " ▁ " ) ; } }

Accumulator variables: count_digits, i, r_digits, sq_n
Iterator variables: i, r_digits
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static bool isKeith ( int x ) { ArrayList terms = new ArrayList ( ) ; while ( temp > 0 ) { terms . Add ( temp % 10 ) ; temp = temp / 10 ; n ++ ; } terms . Reverse ( ) ; int next_term = 0 , i = n ; while ( next_term < x ) { next_term = 0 ; for ( int j = 1 ; j <= n ; j ++ ) next_term += ( int ) terms [ i - j ] ; terms . Add ( next_term ) ; i ++ ; } return ( next_term == x ) ; } public static void Main ( ) { if ( isKeith ( 14 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; if ( isKeith ( 12 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; if ( isKeith ( 197 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Accumulator variables: i, j, n, next_term
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; class Test { static bool canBeSumofConsec ( int n ) { return ( ( ( n & ( n - 1 ) ) != 0 ) && n != 0 ) ; } public static void Main ( ) { int n = 15 ; Console . Write ( canBeSumofConsec ( n ) ? " True " : " False " ) ; } }

Class/struct names: Test
C# program:
using System ; class GFG { static int evenFibSum ( int limit ) { if ( limit < 2 ) return 0 ; long ef1 = 0 , ef2 = 2 ; long sum = ef1 + ef2 ; while ( ef2 <= limit ) { long ef3 = 4 * ef2 + ef1 ; if ( ef3 > limit ) break ; ef1 = ef2 ; ef2 = ef3 ; sum += ef2 ; } return ( int ) sum ; } public static void Main ( ) { int limit = 400 ; Console . Write ( evenFibSum ( limit ) ) ; } }

Accumulator variables: sum
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPerfect ( int n ) { int s = ( int ) ( Math . Sqrt ( n ) ) ; return ( s * s == n ) ; } static int divisorsCount ( int n ) { int count = 0 ; for ( int i = 1 ; i <= Math . Sqrt ( n ) + 1 ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) count += 1 ; else count += 2 ; } } return count ; } static int kDivisors ( int a , int b , int k ) { int count = 0 ; for ( int i = a ; i <= b ; i ++ ) { if ( isPerfect ( i ) ) if ( divisorsCount ( i ) == k ) count ++ ; } return count ; } public static void Main ( String [ ] args ) { int a = 21 , b = 149 , k = 333 ; Console . Write ( kDivisors ( a , b , k ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long evenFib ( int n ) { if ( n < 1 ) return n ; if ( n == 1 ) return 2 ; return ( ( 4 * evenFib ( n - 1 ) ) + evenFib ( n - 2 ) ) ; } public static void Main ( ) { int n = 7 ; Console . Write ( evenFib ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int maxn = 10005 ; static int INF = 999999 ; static int [ ] smallest_prime = new int [ maxn ] ; static int [ ] divisors = new int [ maxn ] ; static int [ ] segmentTree = new int [ 4 * maxn ] ; static void findSmallestPrimeFactors ( ) { for ( int i = 0 ; i < maxn ; i ++ ) smallest_prime [ i ] = INF ; for ( int i = 2 ; i < maxn ; i ++ ) { if ( smallest_prime [ i ] == INF ) { smallest_prime [ i ] = i ; for ( int j = i * i ; j < maxn ; j += i ) if ( smallest_prime [ j ] > i ) smallest_prime [ j ] = i ; } } } static void buildDivisorsArray ( ) { for ( int i = 1 ; i < maxn ; i ++ ) { divisors [ i ] = 1 ; int n = i , p = smallest_prime [ i ] , k = 0 ; while ( n > 1 ) { n = n / p ; k ++ ; if ( smallest_prime [ n ] != p ) { divisors [ i ] = divisors [ i ] * ( k + 1 ) ; k = 0 ; } p = smallest_prime [ n ] ; } } } static void buildSegtmentTree ( int node , int a , int b ) { if ( a == b ) { segmentTree [ node ] = divisors [ a ] ; return ; } buildSegtmentTree ( 2 * node , a , ( a + b ) / 2 ) ; buildSegtmentTree ( 2 * node + 1 , ( ( a + b ) / 2 ) + 1 , b ) ; segmentTree [ node ] = Math . Max ( segmentTree [ 2 * node ] , segmentTree [ 2 * node + 1 ] ) ; } static int query ( int node , int a , int b , int l , int r ) { if ( l > b a > r ) return - 1 ; if ( a >= l && b <= r ) return segmentTree [ node ] ; return Math . Max ( query ( 2 * node , a , ( a + b ) / 2 , l , r ) , query ( 2 * node + 1 , ( ( a + b ) / 2 ) + 1 , b , l , r ) ) ; } public static void Main ( String [ ] args ) { findSmallestPrimeFactors ( ) ; buildDivisorsArray ( ) ; buildSegtmentTree ( 1 , 1 , maxn - 1 ) ; Console . WriteLine ( " Maximum ▁ divisors ▁ that ▁ a ▁ number ▁ " + " has ▁ in ▁ [ 1 , ▁ 100 ] ▁ are ▁ " + query ( 1 , 1 , maxn - 1 , 1 , 100 ) ) ; Console . WriteLine ( " Maximum ▁ divisors ▁ that ▁ a ▁ number ▁ " + " has ▁ in ▁ [ 10 , ▁ 48 ] ▁ are ▁ " + query ( 1 , 1 , maxn - 1 , 10 , 48 ) ) ; Console . WriteLine ( " Maximum ▁ divisors ▁ that ▁ a ▁ number ▁ " + " has ▁ in ▁ [ 1 , ▁ 10 ] ▁ are ▁ " + query ( 1 , 1 , maxn - 1 , 1 , 10 ) ) ; } }

Index/key variables: a, i, j, maxn, n, node
Accumulator variables: i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System . Collections . Generic ; class GFG { static int MAX = 3000 ; public static int smartNumber ( int n ) { int [ ] primes = new int [ MAX ] ; List < int > result = new List < int > ( ) ; for ( int i = 2 ; i < MAX ; i ++ ) { if ( primes [ i ] == 0 ) { primes [ i ] = 1 ; for ( int j = i * 2 ; j < MAX ; j = j + i ) { primes [ j ] -= 1 ; if ( ( primes [ j ] + 3 ) == 0 ) result . Add ( j ) ; } } } result . Sort ( ) ; return result [ n - 1 ] ; } public static void Main ( ) { int n = 50 ; System . Console . WriteLine ( smartNumber ( n ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSteps ( int x , int y ) { if ( x % y == 0 ) return x / y ; return x / y + countSteps ( y , x % y ) ; } static public void Main ( ) { int x = 100 , y = 19 ; Console . WriteLine ( countSteps ( x , y ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static Dictionary < int , int > ma = new Dictionary < int , int > ( ) ; static void primeFactorize ( int a ) { for ( int i = 2 ; i * i <= a ; i += 2 ) { int cnt = 0 ; while ( a % i == 0 ) { cnt ++ ; a /= i ; } ma . Add ( i , cnt ) ; } if ( a > 1 ) ma . Add ( a , 1 ) ; } static int commDiv ( int a , int b ) { primeFactorize ( a ) ; int res = 1 ; foreach ( KeyValuePair < int , int > m in ma ) { int cnt = 0 ; int key = m . Key ; int value = m . Value ; while ( b % key == 0 ) { b /= key ; cnt ++ ; } res *= ( Math . Min ( cnt , value ) + 1 ) ; } return res ; } static void Main ( ) { int a = 12 , b = 24 ; Console . WriteLine ( commDiv ( a , b ) ) ; } }

Accumulator variables: a, b, cnt, i, res
Iterator variables: i, m
Class/struct names: GFG
C# program:
using System ; class GFG { static int findCountOfSolutions ( int n , int p ) { int ans = 0 ; for ( int x = 1 ; x < p ; x ++ ) { if ( ( x * x ) % p == 1 ) { int last = x + p * ( n / p ) ; if ( last > n ) last -= p ; ans += ( ( last - x ) / p + 1 ) ; } } return ans ; } static public void Main ( ) { int n = 10 ; int p = 5 ; Console . WriteLine ( findCountOfSolutions ( n , p ) ) ; } }

Accumulator variables: ans, last, x
Iterator variables: x
Class/struct names: GFG
C# program:
using System ; class GFG { static int kaprekarRec ( int n , int prev ) { if ( n == 0 ) return 0 ; prev = n ; int [ ] digits = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { digits [ i ] = n % 10 ; n = n / 10 ; } Array . Sort ( digits ) ; int asc = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) asc = asc * 10 + digits [ i ] ; Array . Sort ( digits ) ; int desc = 0 ; for ( int i = 3 ; i >= 0 ; i -- ) desc = desc * 10 + digits [ i ] ; int diff = Math . Abs ( asc - desc ) ; if ( diff == prev ) return diff ; return kaprekarRec ( diff , prev ) ; } static int kaprekar ( int n ) { int prev = 0 ; return kaprekarRec ( n , prev ) ; } public static void Main ( ) { System . Console . WriteLine ( kaprekar ( 1000 ) ) ; System . Console . WriteLine ( kaprekar ( 1112 ) ) ; System . Console . WriteLine ( kaprekar ( 9812 ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static float sqroot ( float s ) { int pSq = 0 ; int N = 0 ; for ( int i = ( int ) ( s ) ; i > 0 ; i -- ) { for ( int j = 1 ; j < i ; j ++ ) { if ( j * j == i ) { pSq = i ; N = j ; break ; } } if ( pSq > 0 ) break ; } float d = s - pSq ; float P = d / ( 2.0f * N ) ; float A = N + P ; float sqrt_of_s = A - ( ( P * P ) / ( 2.0f * A ) ) ; return sqrt_of_s ; } public static void Main ( ) { float num = 9.2345f ; float sqroot_of_num = sqroot ( num ) ; Console . Write ( " Square ▁ root ▁ of ▁ " + num + " ▁ = ▁ " + Math . Round ( sqroot_of_num * 100000.0 ) / 100000.0 ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
class GFG { static int power ( int x , int a ) { int res = 1 ; while ( a > 0 ) { if ( ( a & 1 ) > 0 ) res = res * x ; x = x * x ; a >>= 1 ; } return res ; } static int breakInteger ( int N ) { if ( N == 2 ) return 1 ; if ( N == 3 ) return 2 ; int maxProduct = - 1 ; switch ( N % 3 ) { case 0 : maxProduct = power ( 3 , N / 3 ) ; break ; case 1 : maxProduct = 2 * 2 * power ( 3 , ( N / 3 ) - 1 ) ; break ; case 2 : maxProduct = 2 * power ( 3 , N / 3 ) ; break ; } return maxProduct ; } public static void Main ( ) { int maxProduct = breakInteger ( 10 ) ; System . Console . WriteLine ( maxProduct ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int digSum ( int n ) { int sum = 0 ; while ( n > 0 sum > 9 ) { if ( n == 0 ) { n = sum ; sum = 0 ; } sum += n % 10 ; n /= 10 ; } return sum ; } public static void Main ( ) { int n = 1234 ; Console . Write ( digSum ( n ) ) ; } }

Accumulator variables: n, sum
Class/struct names: GFG
C# program:
using System ; class GFG { static int digSum ( int n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } public static void Main ( ) { int n = 9999 ; Console . Write ( digSum ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int countMultiples ( int n ) { return n / 3 + n / 7 - n / 21 ; } static public void Main ( ) { Console . WriteLine ( " Count ▁ = ▁ " + countMultiples ( 25 ) ) ; } }

Class/struct names: GFG