dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int sumOfDigitsFrom1ToNUtil ( int n , int [ ] a ) { if ( n < 10 ) return ( n * ( n + 1 ) / 2 ) ; int d = ( int ) ( Math . Log10 ( n ) ) ; int p = ( int ) ( Math . Ceiling ( Math . Pow ( 10 , d ) ) ) ; int msd = n / p ; return ( msd * a [ d ] + ( msd * ( msd - 1 ) / 2 ) * p + msd * ( 1 + n % p ) + sumOfDigitsFrom1ToNUtil ( n % p , a ) ) ; } static int sumOfDigitsFrom1ToN ( int n ) { int d = ( int ) ( Math . Log10 ( n ) ) ; int [ ] a = new int [ d + 1 ] ; a [ 0 ] = 0 ; a [ 1 ] = 45 ; for ( int i = 2 ; i <= d ; i ++ ) a [ i ] = a [ i - 1 ] * 10 + 45 * ( int ) ( Math . Ceiling ( Math . Pow ( 10 , i - 1 ) ) ) ; return sumOfDigitsFrom1ToNUtil ( n , a ) ; } public static void Main ( String [ ] args ) { int n = 328 ; Console . WriteLine ( " Sum ▁ of ▁ digits ▁ in ▁ numbers ▁ " + " from ▁ 1 ▁ to ▁ " + n + " ▁ is ▁ " + sumOfDigitsFrom1ToN ( n ) ) ; } }

Index/key variables: d, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countWays ( int N ) { if ( N == 1 ) return 4 ; int countB = 1 , countS = 1 , prev_countB , prev_countS ; for ( int i = 2 ; i <= N ; i ++ ) { prev_countB = countB ; prev_countS = countS ; countS = prev_countB + prev_countS ; countB = prev_countS ; } int result = countS + countB ; return ( result * result ) ; } public static void Main ( ) { int N = 3 ; Console . Write ( countWays ( N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int min ( int x , int y ) { return ( x < y ) ? x : y ; } class node { public int data ; public int vc ; public node left , right ; } ; static int vCover ( node root ) { if ( root == null ) return 0 ; if ( root . left == null && root . right == null ) return 0 ; if ( root . vc != 0 ) return root . vc ; int size_incl = 1 + vCover ( root . left ) + vCover ( root . right ) ; int size_excl = 0 ; if ( root . left != null ) size_excl += 1 + vCover ( root . left . left ) + vCover ( root . left . right ) ; if ( root . right != null ) size_excl += 1 + vCover ( root . right . left ) + vCover ( root . right . right ) ; root . vc = Math . Min ( size_incl , size_excl ) ; return root . vc ; } static node newNode ( int data ) { node temp = new node ( ) ; temp . data = data ; temp . left = temp . right = null ; temp . vc = 0 ; return temp ; } public static void Main ( String [ ] args ) { node root = newNode ( 20 ) ; root . left = newNode ( 8 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 12 ) ; root . left . right . left = newNode ( 10 ) ; root . left . right . right = newNode ( 14 ) ; root . right = newNode ( 22 ) ; root . right . right = newNode ( 25 ) ; Console . Write ( " Size ▁ of ▁ the ▁ smallest ▁ vertex " + " cover ▁ is ▁ { 0 } ▁ " , vCover ( root ) ) ; } }

Accumulator variables: size_excl
Class/struct names: GFG, node
C# program:
using System ; class GFG { static int count ( int n ) { int [ ] table = new int [ n + 1 ] ; for ( int j = 0 ; j < n + 1 ; j ++ ) table [ j ] = 0 ; table [ 0 ] = 1 ; for ( int i = 3 ; i <= n ; i ++ ) table [ i ] += table [ i - 3 ] ; for ( int i = 5 ; i <= n ; i ++ ) table [ i ] += table [ i - 5 ] ; for ( int i = 10 ; i <= n ; i ++ ) table [ i ] += table [ i - 10 ] ; return table [ n ] ; } public static void Main ( ) { int n = 20 ; Console . WriteLine ( " Count ▁ for ▁ " + n + " ▁ is ▁ " + count ( n ) ) ; n = 13 ; Console . Write ( " Count ▁ for ▁ " + n + " ▁ is ▁ " + count ( n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static void search ( String txt , String pat ) { int M = pat . Length ; int N = txt . Length ; for ( int i = 0 ; i <= N - M ; i ++ ) { int j ; for ( j = 0 ; j < M ; j ++ ) if ( txt [ i + j ] != pat [ j ] ) break ; if ( j == M ) Console . WriteLine ( " Pattern ▁ found ▁ at ▁ index ▁ " + i ) ; } } public static void Main ( ) { String txt = " AABAACAADAABAAABAA " ; String pat = " AABA " ; search ( txt , pat ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { public readonly static int d = 256 ; static void search ( String pat , String txt , int q ) { int M = pat . Length ; int N = txt . Length ; int i , j ; int p = 0 ; int t = 0 ; int h = 1 ; for ( i = 0 ; i < M - 1 ; i ++ ) h = ( h * d ) % q ; for ( i = 0 ; i < M ; i ++ ) { p = ( d * p + pat [ i ] ) % q ; t = ( d * t + txt [ i ] ) % q ; } for ( i = 0 ; i <= N - M ; i ++ ) { if ( p == t ) { for ( j = 0 ; j < M ; j ++ ) { if ( txt [ i + j ] != pat [ j ] ) break ; } if ( j == M ) Console . WriteLine ( " Pattern ▁ found ▁ at ▁ index ▁ " + i ) ; } if ( i < N - M ) { t = ( d * ( t - txt [ i ] * h ) + txt [ i + M ] ) % q ; if ( t < 0 ) t = ( t + q ) ; } } } public static void Main ( ) { String txt = " GEEKS ▁ FOR ▁ GEEKS " ; String pat = " GEEK " ; int q = 101 ; search ( pat , txt , q ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public const int MAX = 256 ; public static bool compare ( char [ ] arr1 , char [ ] arr2 ) { for ( int i = 0 ; i < MAX ; i ++ ) { if ( arr1 [ i ] != arr2 [ i ] ) { return false ; } } return true ; } public static void search ( string pat , string txt ) { int M = pat . Length ; int N = txt . Length ; char [ ] countP = new char [ MAX ] ; char [ ] countTW = new char [ MAX ] ; for ( int i = 0 ; i < M ; i ++ ) { ( countP [ pat [ i ] ] ) ++ ; ( countTW [ txt [ i ] ] ) ++ ; } for ( int i = M ; i < N ; i ++ ) { if ( compare ( countP , countTW ) ) { Console . WriteLine ( " Found ▁ at ▁ Index ▁ " + ( i - M ) ) ; } ( countTW [ txt [ i ] ] ) ++ ; countTW [ txt [ i - M ] ] -- ; } if ( compare ( countP , countTW ) ) { Console . WriteLine ( " Found ▁ at ▁ Index ▁ " + ( N - M ) ) ; } } public static void Main ( string [ ] args ) { string txt = " BACDGABCDA " ; string pat = " ABCD " ; search ( pat , txt ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findLongestPalindromicString ( String text ) { int N = text . Length ; if ( N == 0 ) return ; N = 2 * N + 1 ; int [ ] L = new int [ N + 1 ] ; L [ 0 ] = 0 ; L [ 1 ] = 1 ; int C = 1 ; int R = 2 ; int i = 0 ; int iMirror ; int maxLPSLength = 0 ; int maxLPSCenterPosition = 0 ; int start = - 1 ; int end = - 1 ; int diff = - 1 ; for ( i = 2 ; i < N ; i ++ ) { iMirror = 2 * C - i ; L [ i ] = 0 ; diff = R - i ; if ( diff > 0 ) L [ i ] = Math . Min ( L [ iMirror ] , diff ) ; while ( ( ( i + L [ i ] ) + 1 < N && ( i - L [ i ] ) > 0 ) && ( ( ( i + L [ i ] + 1 ) % 2 == 0 ) || ( text [ ( i + L [ i ] + 1 ) / 2 ] == text [ ( i - L [ i ] - 1 ) / 2 ] ) ) ) { L [ i ] ++ ; } if ( L [ i ] > maxLPSLength ) { maxLPSLength = L [ i ] ; maxLPSCenterPosition = i ; } if ( i + L [ i ] > R ) { C = i ; R = i + L [ i ] ; } } start = ( maxLPSCenterPosition - maxLPSLength ) / 2 ; end = start + maxLPSLength - 1 ; Console . Write ( " LPS ▁ of ▁ string ▁ is ▁ { 0 } ▁ : ▁ " , text ) ; for ( i = start ; i <= end ; i ++ ) Console . Write ( text [ i ] ) ; Console . WriteLine ( ) ; } public static void Main ( String [ ] args ) { String text = " babcbabcbaccba " ; findLongestPalindromicString ( text ) ; text = " abaaba " ; findLongestPalindromicString ( text ) ; text = " abababa " ; findLongestPalindromicString ( text ) ; text = " abcbabcbabcba " ; findLongestPalindromicString ( text ) ; text = " forgeeksskeegfor " ; findLongestPalindromicString ( text ) ; text = " caba " ; findLongestPalindromicString ( text ) ; text = " abacdfgdcaba " ; findLongestPalindromicString ( text ) ; text = " abacdfgdcabba " ; findLongestPalindromicString ( text ) ; text = " abacdedcaba " ; findLongestPalindromicString ( text ) ; } }

Index/key variables: i, iMirror
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printPatternUtil ( string str , char [ ] buf , int i , int j , int n ) { if ( i == n ) { buf [ j ] = ' \0' ; Console . WriteLine ( buf ) ; return ; } buf [ j ] = str [ i ] ; printPatternUtil ( str , buf , i + 1 , j + 1 , n ) ; buf [ j ] = ' ▁ ' ; buf [ j + 1 ] = str [ i ] ; printPatternUtil ( str , buf , i + 1 , j + 2 , n ) ; } static void printPattern ( string str ) { int len = str . Length ; char [ ] buf = new char [ 2 * len ] ; buf [ 0 ] = str [ 0 ] ; printPatternUtil ( str , buf , 1 , 1 , len ) ; } public static void Main ( ) { string str = " ABCD " ; printPattern ( str ) ; } }

Index/key variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMedian ( int [ ] ar1 , int [ ] ar2 , int n ) { int i = 0 ; int j = 0 ; int count ; int m1 = - 1 , m2 = - 1 ; for ( count = 0 ; count <= n ; count ++ ) { if ( i == n ) { m1 = m2 ; m2 = ar2 [ 0 ] ; break ; } else if ( j == n ) { m1 = m2 ; m2 = ar1 [ 0 ] ; break ; } if ( ar1 [ i ] <= ar2 [ j ] ) { m1 = m2 ; m2 = ar1 [ i ] ; i ++ ; } else { m1 = m2 ; m2 = ar2 [ j ] ; j ++ ; } } return ( m1 + m2 ) / 2 ; } public static void Main ( ) { int [ ] ar1 = { 1 , 12 , 15 , 26 , 38 } ; int [ ] ar2 = { 2 , 13 , 17 , 30 , 45 } ; int n1 = ar1 . Length ; int n2 = ar2 . Length ; if ( n1 == n2 ) Console . Write ( " Median ▁ is ▁ " + getMedian ( ar1 , ar2 , n1 ) ) ; else Console . Write ( " arrays ▁ are ▁ of ▁ unequal ▁ size " ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: count
Class/struct names: GFG
C# program:
using System ; class GfG { static int getMedian ( int [ ] a , int [ ] b , int startA , int startB , int endA , int endB ) { if ( endA - startA == 1 ) { return ( Math . Max ( a [ startA ] , b [ startB ] ) + Math . Min ( a [ endA ] , b [ endB ] ) ) / 2 ; } int m1 = median ( a , startA , endA ) ; int m2 = median ( b , startB , endB ) ; if ( m1 == m2 ) { return m1 ; } else if ( m1 < m2 ) { return getMedian ( a , b , ( endA + startA + 1 ) / 2 , startB , endA , ( endB + startB + 1 ) / 2 ) ; } else { return getMedian ( a , b , startA , ( endB + startB + 1 ) / 2 , ( endA + startA + 1 ) / 2 , endB ) ; } } static int median ( int [ ] arr , int start , int end ) { int n = end - start + 1 ; if ( n % 2 == 0 ) { return ( arr [ start + ( n / 2 ) ] + arr [ start + ( n / 2 - 1 ) ] ) / 2 ; } else { return arr [ start + n / 2 ] ; } } public static void Main ( String [ ] args ) { int [ ] ar1 = { 1 , 2 , 3 , 6 } ; int [ ] ar2 = { 4 , 6 , 8 , 10 } ; int n1 = ar1 . Length ; int n2 = ar2 . Length ; if ( n1 != n2 ) { Console . WriteLine ( " Doesn ' t ▁ work ▁ for ▁ arrays ▁ " + " of ▁ unequal ▁ size " ) ; } else if ( n1 == 0 ) { Console . WriteLine ( " Arrays ▁ are ▁ empty . " ) ; } else if ( n1 == 1 ) { Console . WriteLine ( ( ar1 [ 0 ] + ar2 [ 0 ] ) / 2 ) ; } else { Console . WriteLine ( " Median ▁ is ▁ " + getMedian ( ar1 , ar2 , 0 , 0 , ar1 . Length - 1 , ar2 . Length - 1 ) ) ; } } }

Index/key variables: endA, endB, startA, startB
Class/struct names: GfG
C# program:
using System ; public class GFG { public static int getMedian ( int [ ] ar1 , int [ ] ar2 , int n ) { int j = 0 ; int i = n - 1 ; while ( ar1 [ i ] > ar2 [ j ] && j < n && i > - 1 ) { int temp = ar1 [ i ] ; ar1 [ i ] = ar2 [ j ] ; ar2 [ j ] = temp ; i -- ; j ++ ; } Array . Sort ( ar1 ) ; Array . Sort ( ar2 ) ; return ( ar1 [ n - 1 ] + ar2 [ 0 ] ) / 2 ; } public static void Main ( String [ ] args ) { int [ ] ar1 = { 1 , 12 , 15 , 26 , 38 } ; int [ ] ar2 = { 2 , 13 , 17 , 30 , 45 } ; int n1 = 5 ; int n2 = 5 ; if ( n1 == n2 ) Console . WriteLine ( " Median ▁ is ▁ " + getMedian ( ar1 , ar2 , n1 ) ) ; else Console . WriteLine ( " Doesn ' t ▁ work ▁ for ▁ arrays ▁ of ▁ unequal ▁ size " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Point { public int x ; public int y ; public Point ( int x , int y ) { this . x = x ; this . y = y ; } } ; static Boolean onSegment ( Point p , Point q , Point r ) { if ( q . x <= Math . Max ( p . x , r . x ) && q . x >= Math . Min ( p . x , r . x ) && q . y <= Math . Max ( p . y , r . y ) && q . y >= Math . Min ( p . y , r . y ) ) return true ; return false ; } static int orientation ( Point p , Point q , Point r ) { int val = ( q . y - p . y ) * ( r . x - q . x ) - ( q . x - p . x ) * ( r . y - q . y ) ; if ( val == 0 ) return 0 ; return ( val > 0 ) ? 1 : 2 ; } static Boolean doIntersect ( Point p1 , Point q1 , Point p2 , Point q2 ) { int o1 = orientation ( p1 , q1 , p2 ) ; int o2 = orientation ( p1 , q1 , q2 ) ; int o3 = orientation ( p2 , q2 , p1 ) ; int o4 = orientation ( p2 , q2 , q1 ) ; if ( o1 != o2 && o3 != o4 ) return true ; if ( o1 == 0 && onSegment ( p1 , p2 , q1 ) ) return true ; if ( o2 == 0 && onSegment ( p1 , q2 , q1 ) ) return true ; if ( o3 == 0 && onSegment ( p2 , p1 , q2 ) ) return true ; if ( o4 == 0 && onSegment ( p2 , q1 , q2 ) ) return true ; return false ; } public static void Main ( String [ ] args ) { Point p1 = new Point ( 1 , 1 ) ; Point q1 = new Point ( 10 , 1 ) ; Point p2 = new Point ( 1 , 2 ) ; Point q2 = new Point ( 10 , 2 ) ; if ( doIntersect ( p1 , q1 , p2 , q2 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; p1 = new Point ( 10 , 1 ) ; q1 = new Point ( 0 , 10 ) ; p2 = new Point ( 0 , 0 ) ; q2 = new Point ( 10 , 10 ) ; if ( doIntersect ( p1 , q1 , p2 , q2 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; p1 = new Point ( - 5 , - 5 ) ; q1 = new Point ( 0 , 0 ) ; p2 = new Point ( 1 , 1 ) ; q2 = new Point ( 10 , 10 ) ; ; if ( doIntersect ( p1 , q1 , p2 , q2 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG, Point
C# program:
using System ; class GFG { static double area ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { return Math . Abs ( ( x1 * ( y2 - y3 ) + x2 * ( y3 - y1 ) + x3 * ( y1 - y2 ) ) / 2.0 ) ; } static bool isInside ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 , int x , int y ) { double A = area ( x1 , y1 , x2 , y2 , x3 , y3 ) ; double A1 = area ( x , y , x2 , y2 , x3 , y3 ) ; double A2 = area ( x1 , y1 , x , y , x3 , y3 ) ; double A3 = area ( x1 , y1 , x2 , y2 , x , y ) ; return ( A == A1 + A2 + A3 ) ; } public static void Main ( ) { if ( isInside ( 0 , 0 , 20 , 0 , 10 , 30 , 10 , 15 ) ) Console . WriteLine ( " Inside " ) ; else Console . WriteLine ( " Not ▁ Inside " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static int counter = 2 ; static bool isLucky ( int n ) { int next_position = n ; if ( counter > n ) return true ; if ( n % counter == 0 ) return false ; next_position -= next_position / counter ; counter ++ ; return isLucky ( next_position ) ; } public static void Main ( ) { int x = 5 ; if ( isLucky ( x ) ) Console . Write ( x + " ▁ is ▁ a ▁ " + " lucky ▁ no . " ) ; else Console . Write ( x + " ▁ is ▁ not " + " ▁ a ▁ lucky ▁ no . " ) ; } }

Accumulator variables: counter, next_position
Class/struct names: GFG
C# program:
using System ; class GFG { static int pow ( int a , int b ) { if ( b == 0 ) return 1 ; int answer = a ; int increment = a ; int i , j ; for ( i = 1 ; i < b ; i ++ ) { for ( j = 1 ; j < a ; j ++ ) { answer += increment ; } increment = answer ; } return answer ; } public static void Main ( ) { Console . Write ( pow ( 5 , 3 ) ) ; } }

Accumulator variables: answer, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int multiply ( int x , int y ) { if ( y > 0 ) return ( x + multiply ( x , y - 1 ) ) ; else return 0 ; } static int pow ( int a , int b ) { if ( b > 0 ) return multiply ( a , pow ( a , b - 1 ) ) ; else return 1 ; } public static void Main ( ) { Console . Write ( pow ( 5 , 3 ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int count ( int n ) { if ( n < 3 ) return n ; if ( n >= 3 && n < 10 ) return n - 1 ; int po = 1 ; while ( n / po > 9 ) po = po * 10 ; int msd = n / po ; if ( msd != 3 ) return count ( msd ) * count ( po - 1 ) + count ( msd ) + count ( n % po ) ; else return count ( msd * po - 1 ) ; } public static void Main ( ) { int n = 578 ; Console . Write ( count ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int maximumNumberDistinctPrimeRange ( int m , int n ) { long [ ] factorCount = new long [ n + 1 ] ; bool [ ] prime = new bool [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { factorCount [ i ] = 0 ; prime [ i ] = true ; } for ( int i = 2 ; i <= n ; i ++ ) { if ( prime [ i ] == true ) { factorCount [ i ] = 1 ; for ( int j = i * 2 ; j <= n ; j += i ) { factorCount [ j ] ++ ; prime [ j ] = false ; } } } int max = ( int ) factorCount [ m ] ; int num = m ; for ( int i = m ; i <= n ; i ++ ) { if ( factorCount [ i ] > max ) { max = ( int ) factorCount [ i ] ; num = i ; } } return num ; } public static void Main ( ) { int m = 4 , n = 6 ; Console . WriteLine ( maximumNumberDistinctPrimeRange ( m , n ) ) ; } }

Index/key variables: i, j, m
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int fact ( int n ) { return ( n <= 1 ) ? 1 : n * fact ( n - 1 ) ; } static int findSmallerInRight ( string str , int low , int high ) { int countRight = 0 , i ; for ( i = low + 1 ; i <= high ; ++ i ) if ( str [ i ] < str [ low ] ) ++ countRight ; return countRight ; } static int findRank ( string str ) { int len = str . Length ; int mul = fact ( len ) ; int rank = 1 ; int countRight ; for ( int i = 0 ; i < len ; ++ i ) { mul /= len - i ; countRight = findSmallerInRight ( str , i , len - 1 ) ; rank += countRight * mul ; } return rank ; } public static void Main ( ) { string str = " string " ; Console . Write ( findRank ( str ) ) ; } }

Index/key variables: i, low
Accumulator variables: mul, rank
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_CHAR = 256 ; int [ ] count = new int [ MAX_CHAR ] ; static int fact ( int n ) { return ( n <= 1 ) ? 1 : n * fact ( n - 1 ) ; } static void populateAndIncreaseCount ( int [ ] count , char [ ] str ) { int i ; for ( i = 0 ; i < str . Length ; ++ i ) ++ count [ str [ i ] ] ; for ( i = 1 ; i < MAX_CHAR ; ++ i ) count [ i ] += count [ i - 1 ] ; } static void updatecount ( int [ ] count , char ch ) { int i ; for ( i = ch ; i < MAX_CHAR ; ++ i ) -- count [ i ] ; } static int findRank ( char [ ] str ) { int len = str . Length ; int mul = fact ( len ) ; int rank = 1 , i ; populateAndIncreaseCount ( count , str ) ; for ( i = 0 ; i < len ; ++ i ) { mul /= len - i ; rank += count [ str [ i ] - 1 ] * mul ; updatecount ( count , str [ i ] ) ; } return rank ; } public static void Main ( String [ ] args ) { char [ ] str = " string " . ToCharArray ( ) ; Console . WriteLine ( findRank ( str ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: mul, rank
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static float exponential ( int n , float x ) { float sum = 1 ; for ( int i = n - 1 ; i > 0 ; -- i ) sum = 1 + x * sum / i ; return sum ; } public static void Main ( ) { int n = 10 ; float x = 1 ; Console . Write ( " e ^ x ▁ = ▁ " + exponential ( n , x ) ) ; } }

Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { return b > 0 ? gcd ( b , a % b ) : a ; } class Vessel { int capacity , current ; public Vessel ( int capacity ) { this . capacity = capacity ; current = 0 ; } public void makeOneLitre ( Vessel V2 ) { if ( gcd ( capacity , V2 . capacity ) != 1 ) return ; while ( current != 1 ) { if ( current == 0 ) current = capacity ; Console . Write ( " Vessel ▁ 1 : ▁ " + current + " ▁ Vessel ▁ 2 : ▁ " + V2 . current + " STRNEWLINE " ) ; current = current - V2 . transfer ( current ) ; } Console . Write ( " Vessel ▁ 1 : ▁ " + current + " ▁ Vessel ▁ 2 : ▁ " + V2 . current + " STRNEWLINE " ) ; } int transfer ( int amount ) { if ( current + amount < capacity ) { current += amount ; return amount ; } int transferred = capacity - current ; current = 0 ; return transferred ; } } public static void Main ( String [ ] args ) { int a = 3 , b = 7 ; Vessel V1 = new Vessel ( a ) ; Vessel V2 = new Vessel ( b ) ; V1 . makeOneLitre ( V2 ) ; } }

Accumulator variables: current
Class/struct names: GFG, Vessel
C# program:
using System ; class GFG { static int findCeil ( int [ ] arr , int r , int l , int h ) { int mid ; while ( l < h ) { mid = l + ( ( h - l ) >> 1 ) ; if ( r > arr [ mid ] ) l = mid + 1 ; else h = mid ; } return ( arr [ l ] >= r ) ? l : - 1 ; } static int myRand ( int [ ] arr , int [ ] freq , int n ) { int [ ] prefix = new int [ n ] ; int i ; prefix [ 0 ] = freq [ 0 ] ; for ( i = 1 ; i < n ; ++ i ) prefix [ i ] = prefix [ i - 1 ] + freq [ i ] ; Random rand = new Random ( ) ; int r = ( ( int ) ( rand . Next ( ) * ( 323567 ) ) % prefix [ n - 1 ] ) + 1 ; int indexc = findCeil ( prefix , r , 0 , n - 1 ) ; return arr [ indexc ] ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int [ ] freq = { 10 , 5 , 20 , 100 } ; int i , n = arr . Length ; for ( i = 0 ; i < 5 ; i ++ ) Console . WriteLine ( myRand ( arr , freq , n ) ) ; } }

Index/key variables: i, indexc, l, mid, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPerfectSquare ( int x ) { int s = ( int ) Math . Sqrt ( x ) ; return ( s * s == x ) ; } static bool isFibonacci ( int n ) { return isPerfectSquare ( 5 * n * n + 4 ) || isPerfectSquare ( 5 * n * n - 4 ) ; } public static void Main ( ) { for ( int i = 1 ; i <= 10 ; i ++ ) Console . WriteLine ( isFibonacci ( i ) ? i + " ▁ is ▁ a ▁ Fibonacci ▁ Number " : i + " ▁ is ▁ a ▁ not ▁ Fibonacci ▁ Number " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findTrailingZeros ( int n ) { int count = 0 ; for ( int i = 5 ; n / i >= 1 ; i *= 5 ) count += n / i ; return count ; } public static void Main ( ) { int n = 100 ; Console . WriteLine ( " Count ▁ of ▁ trailing ▁ 0s ▁ in ▁ " + n + " ! ▁ is ▁ " + findTrailingZeros ( n ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int catalan ( int n ) { if ( n <= 1 ) { return 1 ; } int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { res += catalan ( i ) * catalan ( n - i - 1 ) ; } return res ; } public static void Main ( ) { for ( int i = 0 ; i < 10 ; i ++ ) Console . Write ( catalan ( i ) + " ▁ " ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static uint catalanDP ( uint n ) { uint [ ] catalan = new uint [ n + 2 ] ; catalan [ 0 ] = catalan [ 1 ] = 1 ; for ( uint i = 2 ; i <= n ; i ++ ) { catalan [ i ] = 0 ; for ( uint j = 0 ; j < i ; j ++ ) catalan [ i ] += catalan [ j ] * catalan [ i - j - 1 ] ; } return catalan [ n ] ; } static void Main ( ) { for ( uint i = 0 ; i < 10 ; i ++ ) Console . Write ( catalanDP ( i ) + " ▁ " ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static long binomialCoeff ( int n , int k ) { long res = 1 ; if ( k > n - k ) { k = n - k ; } for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } static long catalan ( int n ) { long c = binomialCoeff ( 2 * n , n ) ; return c / ( n + 1 ) ; } public static void Main ( ) { for ( int i = 0 ; i < 10 ; i ++ ) { Console . Write ( catalan ( i ) + " ▁ " ) ; } } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void catalan ( int n ) { int cat_ = 1 ; Console . Write ( cat_ + " ▁ " ) ; for ( int i = 1 ; i < n ; i ++ ) { cat_ *= ( 4 * i - 2 ) ; cat_ /= ( i + 1 ) ; Console . Write ( cat_ + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int n = 5 ; catalan ( n ) ; } }

Accumulator variables: cat_, i
Iterator variables: i
Class/struct names: GFG