dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static float pi = 3.14159f ; public static float volume ( float r , float h ) { return ( float ) 1 / 3 * pi * h * r * r ; } public static float surface_area ( float r , float s ) { return pi * r * s + pi * r * r ; } public static void main ( String args [ ] ) { float radius = 5 ; float slant_height = 13 ; float height = 12 ; float vol , sur_area ; System . out . print ( " Volume ▁ Of ▁ Cone ▁ : ▁ " ) ; System . out . println ( volume ( radius , height ) ) ; System . out . print ( " Surface ▁ Area ▁ Of ▁ Cone ▁ : ▁ " ) ; System . out . println ( surface_area ( radius , slant_height ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class solution { static int nthTerm ( int n ) { return 6 * ( int ) Math . pow ( n , 2 ) - 4 * n - 2 ; } public static void main ( String arr [ ] ) { int N = 4 ; System . out . println ( nthTerm ( N ) ) ; } }

Class/struct names: solution
Java program:
import java . util . * ; class solution { static int nthTerm ( int n ) { return ( int ) Math . pow ( n , 2 ) + 2 * n + 2 ; } public static void main ( String arr [ ] ) { int N = 4 ; System . out . println ( nthTerm ( N ) ) ; } }

Class/struct names: solution
Java program:
import java . util . * ; class solution { static int sum ( int n ) { int ans = ( n * ( n - 1 ) ) / 2 ; return ans ; } public static void main ( String arr [ ] ) { int n = 5 ; System . out . println ( sum ( n ) ) ; } }

Class/struct names: solution
Java program:
import java . util . * ; class solution { static long getNthTerm ( long N ) { return 4 * ( long ) Math . pow ( N , 2 ) - 3 * N + 2 ; } public static void main ( String arr [ ] ) { long N = 10 ; System . out . println ( getNthTerm ( N ) ) ; } }

Class/struct names: solution
Java program:
public class GFG { static long MOD = 1000000007 ; static long power ( long x , long y , long p ) { long res = 1 ; x = x % p ; while ( y > 0 ) { if ( ( y & 1 ) != 0 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } static long sumProd ( long n , long t ) { long dino = power ( t + 1 , MOD - 2 , MOD ) ; long ans = 1 ; for ( long i = n + t + 1 ; i > n ; -- i ) ans = ( ans % MOD * i % MOD ) % MOD ; long tfact = 1 ; for ( int i = 1 ; i <= t ; ++ i ) tfact = ( tfact * i ) % MOD ; ans = ans * dino - tfact + MOD ; return ans % MOD ; } public static void main ( String [ ] args ) { long n = 3 , t = 2 ; System . out . println ( sumProd ( n , t ) ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int calculateSum ( int n ) { return ( n * ( ( int ) Math . pow ( n , 2 ) + 3 * n + 5 ) ) / 3 ; } public static void main ( String arr [ ] ) { int n = 25 ; System . out . println ( calculateSum ( n ) ) ; } }

Class/struct names: GFG
Java program:
public class TYU { static long mod = 1000000007 ; static long power ( long a , long b ) { long res = 1 ; while ( b != 0 ) { if ( ( b & 1 ) != 0 ) { res *= a ; res %= mod ; } b /= 2 ; a *= a ; a %= mod ; } return res ; } static long minPlayer ( long n , long k ) { long num = ( ( power ( k , n ) - 1 ) + mod ) % mod ; long den = ( power ( k - 1 , mod - 2 ) + mod ) % mod ; long ans = ( ( ( num * den ) % mod ) * k ) % mod ; return ans ; } public static void main ( String [ ] args ) { long n = 3 , k = 3 ; System . out . println ( minPlayer ( n , k ) ) ; } }

Accumulator variables: a, b, res
Class/struct names: TYU
Java program:
public class GFG { static void sieveOfEratosthenes ( int N , int s [ ] ) { boolean [ ] prime = new boolean [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) prime [ i ] = false ; for ( int i = 2 ; i <= N ; i += 2 ) s [ i ] = 2 ; for ( int i = 3 ; i <= N ; i += 2 ) { if ( prime [ i ] == false ) { s [ i ] = i ; for ( int j = i ; j * i <= N ; j += 2 ) { if ( prime [ i * j ] == false ) { prime [ i * j ] = true ; s [ i * j ] = i ; } } } } } static int findSum ( int N ) { int [ ] s = new int [ N + 1 ] ; int ans = 1 ; sieveOfEratosthenes ( N , s ) ; int currFactor = s [ N ] ; int power = 1 ; while ( N > 1 ) { N /= s [ N ] ; if ( currFactor == s [ N ] ) { power ++ ; continue ; } int sum = 0 ; for ( int i = 0 ; i <= power ; i ++ ) sum += Math . pow ( currFactor , i ) ; ans *= sum ; currFactor = s [ N ] ; power = 1 ; } return ans ; } public static void main ( String [ ] args ) { int n = 12 ; System . out . print ( " Sum ▁ of ▁ the ▁ factors ▁ is ▁ : ▁ " ) ; System . out . print ( findSum ( n ) ) ; } }

Index/key variables: N, i
Accumulator variables: N, ans, i, j, power, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int count_setbits ( int N ) { int cnt = 0 ; while ( N > 0 ) { cnt += ( N & 1 ) ; N = N >> 1 ; } return cnt ; } static int countMultiples ( int n ) { int multiple [ ] = { 2 , 3 , 5 } ; int count = 0 , mask = ( int ) Math . pow ( 2 , 3 ) ; for ( int i = 1 ; i < mask ; i ++ ) { int prod = 1 ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( ( i & 1 << j ) > 0 ) prod = prod * multiple [ j ] ; } if ( count_setbits ( i ) % 2 == 1 ) count = count + n / prod ; else count = count - n / prod ; } return count ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( countMultiples ( n ) ) ; } }

Index/key variables: j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int findN ( int k ) { int ans ; if ( k == 0 ) ans = 3 ; if ( k == 1 ) ans = 1 ; else if ( k % 4 == 0 ) ans = k ; else if ( k % 4 == 3 ) ans = k - 1 ; else ans = - 1 ; return ans ; } public static void main ( String [ ] args ) { int k = 7 ; int res = findN ( k ) ; if ( res == - 1 ) System . out . println ( " Not ▁ possible " ) ; else System . out . println ( res ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int Circular ( int n ) { int Result = 1 ; while ( n > 0 ) { Result = Result * n ; n -- ; } return Result ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( Circular ( n - 1 ) ) ; } }

Accumulator variables: n
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static double calTime ( double arr [ ] , int n ) { double work = 0 ; for ( int i = 0 ; i < n ; i ++ ) work += 1 / arr [ i ] ; return 1 / work ; } public static void main ( String [ ] args ) { double arr [ ] = { 6.0 , 3.0 , 4.0 } ; int n = arr . length ; System . out . println ( calTime ( arr , n ) + " ▁ Hours " ) ; } }

Index/key variables: i
Accumulator variables: i, work
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void printTwins ( int low , int high ) { boolean prime [ ] = new boolean [ high + 1 ] ; boolean twin = false ; for ( int i = 0 ; i < high + 1 ; i ++ ) prime [ i ] = true ; prime [ 0 ] = prime [ 1 ] = false ; for ( int p = 2 ; p <= Math . floor ( Math . sqrt ( high ) ) + 1 ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= high ; i += p ) prime [ i ] = false ; } } for ( int i = high ; i >= low ; i -- ) { if ( prime [ i ] && ( i - 2 >= low && prime [ i - 2 ] == true ) ) { System . out . println ( " Largest ▁ twins ▁ in ▁ given ▁ range : ▁ ( " + ( i - 2 ) + " , ▁ " + ( i ) + " ) " ) ; twin = true ; break ; } } if ( twin == false ) System . out . println ( " No ▁ such ▁ pair ▁ exists " ) ; } public static void main ( String [ ] args ) { printTwins ( 10 , 100 ) ; } }

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Boolean variables: twin
Class/struct names: GFG
Java program:
class GFG { static int prevComplement ( int n , int b ) { int maxDigit , maxNum = 0 , digits = 0 , num = n ; while ( n != 0 ) { digits ++ ; n = n / 10 ; } maxDigit = b - 1 ; while ( ( digits -- ) > 0 ) { maxNum = maxNum * 10 + maxDigit ; } return maxNum - num ; } static int complement ( int n , int b ) { return prevComplement ( n , b ) + 1 ; } public static void main ( String args [ ] ) { System . out . println ( prevComplement ( 25 , 7 ) ) ; System . out . println ( complement ( 25 , 7 ) ) ; } }

Accumulator variables: digits
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { public static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } public static void main ( String [ ] args ) { int a = 2 ; int b = 4 ; System . out . println ( gcd ( a , b ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int MaximumDivisors ( int X , int Y ) { int [ ] arr = new int [ Y - X + 1 ] ; for ( int i = 0 ; i < arr . length ; i ++ ) arr [ i ] = 0 ; int mx = 0 ; int cnt = 0 ; for ( int i = 1 ; i * i <= Y ; i ++ ) { int sq = i * i ; int first_divisible ; if ( ( X / i ) * i >= X ) first_divisible = ( X / i ) * i ; else first_divisible = ( X / i + 1 ) * i ; for ( int j = first_divisible ; j <= Y ; j += i ) { if ( j < sq ) continue ; else if ( j == sq ) arr [ j - X ] ++ ; else arr [ j - X ] += 2 ; } } for ( int i = X ; i <= Y ; i ++ ) { if ( arr [ i - X ] > mx ) { cnt = 1 ; mx = arr [ i - X ] ; } else if ( arr [ i - X ] == mx ) cnt ++ ; } return cnt ; } public static void main ( String [ ] args ) { int X = 1 , Y = 10 ; System . out . println ( MaximumDivisors ( X , Y ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int power ( int x , int y , int p ) { int res = 1 ; x = x % p ; while ( y > 0 ) { if ( ( y & 1 ) != 0 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } static int NearestElement ( int A , int D , int P ) { if ( A == 0 ) return 0 ; else if ( D == 0 ) return - 1 ; else { int X = power ( D , P - 2 , P ) ; return ( X * ( P - A ) ) % P ; } } public static void main ( String args [ ] ) { int A = 4 , D = 9 , P = 11 ; A %= P ; D %= P ; System . out . println ( NearestElement ( A , D , P ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void print ( int p0 ) { int p1 , i = 0 , x , flag , k ; while ( true ) { flag = 1 ; x = ( int ) ( Math . pow ( 2 , i ) ) ; p1 = x * p0 + ( x - 1 ) ; for ( k = 2 ; k < p1 ; k ++ ) { if ( p1 % k == 0 ) { flag = 0 ; break ; } } if ( flag == 0 ) break ; System . out . print ( " ▁ " + p1 ) ; i ++ ; } } public static void main ( String args [ ] ) { int p0 = 2 ; print ( p0 ) ; } }

Accumulator variables: i, k
Iterator variables: k
Class/struct names: GFG
Java program:
class solution_1 { static int findOddPair ( int A [ ] , int N ) { int i , j ; int oddPair = 0 ; for ( i = 0 ; i < N ; i ++ ) { for ( j = i + 1 ; j < N ; j ++ ) { if ( ( A [ i ] & A [ j ] ) % 2 != 0 ) oddPair ++ ; } } return oddPair ; } public static void main ( String args [ ] ) { int a [ ] = { 5 , 1 , 3 , 2 } ; int n = a . length ; System . out . println ( findOddPair ( a , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, oddPair
Iterator variables: i, j
Class/struct names: solution_1
Java program:
class GFG { static int summ ( int n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } static void printDigitalRoot ( int n ) { int maxi = 1 ; int dig = 1 ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { int d1 = summ ( n / i ) ; int d2 = summ ( i ) ; if ( d1 > maxi ) { dig = n / i ; maxi = d1 ; } if ( d2 > maxi ) { dig = i ; maxi = d2 ; } if ( d1 == maxi ) { if ( dig < ( n / i ) ) { dig = n / i ; maxi = d1 ; } } if ( d2 == maxi ) { if ( dig < i ) { dig = i ; maxi = d2 ; } } } } System . out . println ( dig + " ▁ " + maxi ) ; } public static void main ( String [ ] args ) { int n = 10 ; printDigitalRoot ( n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static long calculateSum ( int n ) { long sum = 0 ; sum = 1 << n ; return ( sum - 1 ) ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( " Sum ▁ of ▁ all ▁ elements : " + calculateSum ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void Divide ( int a , int b ) { long dividend = ( long ) a ; long divisor = ( long ) b ; long sign = ( dividend < 0 ) ^ ( divisor < 0 ) ? - 1 : 1 ; dividend = Math . abs ( dividend ) ; divisor = Math . abs ( divisor ) ; if ( divisor == 0 ) { System . out . println ( " Cannot ▁ Divide ▁ by ▁ 0" ) ; return ; } if ( dividend == 0 ) { System . out . println ( a + " ▁ / ▁ " + b + " ▁ is ▁ equal ▁ to ▁ : ▁ " + 0 ) ; return ; } if ( divisor == 1 ) { System . out . println ( a + " ▁ / ▁ " + b + " ▁ is ▁ equal ▁ to ▁ : ▁ " + sign * dividend ) ; return ; } System . out . println ( a + " ▁ / ▁ " + b + " ▁ is ▁ equal ▁ to ▁ : ▁ " + Math . floor ( sign * ( Math . exp ( Math . log ( dividend ) - Math . log ( divisor ) ) ) ) ) ; } public static void main ( String [ ] args ) { int a = 10 , b = 5 ; Divide ( a , b ) ; a = 49 ; b = - 7 ; Divide ( a , b ) ; } }

Class/struct names: GFG
Java program:
class GFG { static boolean findNature ( int a , int b , int n ) { if ( n == 0 ) return ( a & 1 ) == 1 ? true : false ; if ( n == 1 ) return ( b & 1 ) == 1 ? true : false ; if ( ( a & 1 ) == 0 ) { if ( ( b & 1 ) == 0 ) return false ; else return ( n % 3 != 0 ) ; } else { if ( ( b & 1 ) == 0 ) return ( ( n - 1 ) % 3 != 0 ) ; else return ( ( n + 1 ) % 3 != 0 ) ; } } public static void main ( String [ ] args ) { int a = 2 , b = 4 ; int n = 3 ; if ( findNature ( a , b , n ) ) System . out . println ( " Odd " ) ; else System . out . println ( " Even " ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String checkEqual ( String S ) { for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) != '1' && S . charAt ( i ) != '0' && S . charAt ( i ) != '8' ) { return " No " ; } } int start = 0 , end = S . length ( ) - 1 ; while ( start < end ) { if ( S . charAt ( start ) != S . charAt ( end ) ) { return " No " ; } start ++ ; end -- ; } return " Yes " ; } public static void main ( String [ ] args ) { String S = "101" ; System . out . println ( checkEqual ( S ) ) ; } }

Accumulator variables: end, i, start
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . io . * ; class GFG { static void check_polydivisible ( int n ) { int N = n ; Vector < Integer > digit = new Vector < Integer > ( ) ; while ( n > 0 ) { digit . add ( new Integer ( n % 10 ) ) ; n /= 10 ; } Collections . reverse ( digit ) ; boolean flag = true ; n = digit . get ( 0 ) ; for ( int i = 1 ; i < digit . size ( ) ; i ++ ) { n = n * 10 + digit . get ( i ) ; if ( n % ( i + 1 ) != 0 ) { flag = false ; break ; } } if ( flag ) System . out . println ( N + " ▁ is ▁ Polydivisible ▁ number . " ) ; else System . out . println ( N + " ▁ is ▁ Not ▁ Polydivisible ▁ number . " ) ; } public static void main ( String [ ] args ) { int n = 345654 ; check_polydivisible ( n ) ; } }

Accumulator variables: i, n
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
Java program:
class GFG { static int Log2n ( int n ) { return ( n > 1 ) ? 1 + Log2n ( n / 2 ) : 0 ; } static boolean isPowerOfd ( int n , int d ) { int count = 0 ; if ( n > 0 && ( n & ( n - 1 ) ) == 0 ) { while ( n > 1 ) { n >>= 1 ; count += 1 ; } return ( count % ( Log2n ( d ) ) == 0 ) ; } return false ; } public static void main ( String [ ] args ) { int n = 64 , d = 8 ; if ( isPowerOfd ( n , d ) ) System . out . println ( n + " ▁ is ▁ a ▁ power ▁ of ▁ " + d ) ; else System . out . println ( n + " ▁ is ▁ not ▁ a ▁ power ▁ of ▁ " + d ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int MAX = 1001 ; static Vector < Integer > [ ] adj = new Vector [ MAX ] ; static void add_edge ( int u , int v ) { adj [ u ] . add ( v ) ; } static void checkTotalNumberofNodes ( int actualAnswer , int size ) { int calculatedAnswer = size ; for ( int i = 1 ; i <= size ; i ++ ) calculatedAnswer += adj [ i ] . size ( ) ; if ( actualAnswer == calculatedAnswer ) System . out . print ( " Calculated ▁ Answer ▁ is ▁ " + calculatedAnswer + " and is Equal to Actual AnswerNEW_LINE"); else System . out . print ( "Calculated Answer is IncorrectNEW_LINE"); } public static void main ( String [ ] args ) { for ( int i = 0 ; i < MAX ; i ++ ) adj [ i ] = new Vector < Integer > ( ) ; int N = 8 ; add_edge ( 1 , 2 ) ; add_edge ( 1 , 3 ) ; add_edge ( 2 , 4 ) ; add_edge ( 2 , 5 ) ; add_edge ( 3 , 6 ) ; add_edge ( 3 , 7 ) ; add_edge ( 6 , 8 ) ; checkTotalNumberofNodes ( 2 * N - 1 , N ) ; for ( int i = 1 ; i <= N ; i ++ ) adj [ i ] . clear ( ) ; N = 9 ; add_edge ( 1 , 2 ) ; add_edge ( 1 , 3 ) ; add_edge ( 2 , 4 ) ; add_edge ( 2 , 5 ) ; add_edge ( 2 , 6 ) ; add_edge ( 3 , 9 ) ; add_edge ( 5 , 7 ) ; add_edge ( 5 , 8 ) ; checkTotalNumberofNodes ( 2 * N - 1 , N ) ; } }

Index/key variables: MAX, i, u
Accumulator variables: calculatedAnswer, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int octahedral_num ( int n ) { return n * ( 2 * n * n + 1 ) / 3 ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . print ( n + " th ▁ Octahedral " + " ▁ number : ▁ " ) ; System . out . println ( octahedral_num ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int centeredTetrahedralNumber ( int n ) { return ( 2 * n + 1 ) * ( n * n + n + 3 ) / 3 ; } public static void main ( String [ ] args ) { int n = 6 ; System . out . println ( centeredTetrahedralNumber ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void swap ( int a , int b , int c , int d ) { a = a + b ; b = a - b ; a = a - b ; b = b + c ; c = b - c ; b = b - c ; c = c + d ; d = c - d ; c = c - d ; System . out . println ( " values ▁ after ▁ " + " swapping ▁ are ▁ : ▁ " ) ; System . out . println ( " a ▁ = ▁ " + a ) ; System . out . println ( " b ▁ = ▁ " + b ) ; System . out . println ( " c ▁ = ▁ " + c ) ; System . out . println ( " d ▁ = ▁ " + d ) ; } public static void main ( String [ ] args ) { int a = 1 ; int b = 2 ; int c = 3 ; int d = 4 ; System . out . println ( " values ▁ before ▁ " + " swapping ▁ are ▁ : ▁ " ) ; System . out . println ( " a ▁ = ▁ " + a ) ; System . out . println ( " b ▁ = ▁ " + b ) ; System . out . println ( " c ▁ = ▁ " + c ) ; System . out . println ( " d ▁ = ▁ " + d ) ; System . out . println ( " " ) ; swap ( a , b , c , d ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int seriesSum ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += i * ( i + 1 ) / 2 ; return sum ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( seriesSum ( n ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int N = 3 ; static boolean checkCentrosymmetricted ( int n , int m [ ] [ ] ) { int mid_row ; if ( ( n & 1 ) > 0 ) mid_row = n / 2 + 1 ; else mid_row = n / 2 ; for ( int i = 0 ; i < mid_row ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( m [ i ] [ j ] != m [ n - i - 1 ] [ n - j - 1 ] ) return false ; } } return true ; } public static void main ( String [ ] args ) { int n = 3 ; int m [ ] [ ] = { { 1 , 3 , 5 } , { 6 , 8 , 6 } , { 5 , 3 , 1 } } ; if ( checkCentrosymmetricted ( n , m ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int Centered_Triangular_num ( int n ) { return ( 3 * n * n + 3 * n + 2 ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( Centered_Triangular_num ( n ) ) ; n = 12 ; System . out . println ( Centered_Triangular_num ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } public static int findGCD ( ArrayList < Integer > arr , int n ) { int result = arr . get ( 0 ) ; for ( int i = 1 ; i < n ; i ++ ) result = gcd ( arr . get ( i ) , result ) ; return result ; } public static void compute ( ArrayList < Integer > arr , int n ) { ArrayList < Integer > answer = new ArrayList < Integer > ( ) ; int GCD_of_array = findGCD ( arr , n ) ; if ( GCD_of_array == arr . get ( 0 ) ) { answer . add ( arr . get ( 0 ) ) ; for ( int i = 1 ; i < n ; i ++ ) { answer . add ( arr . get ( 0 ) ) ; answer . add ( arr . get ( i ) ) ; } for ( int i = 0 ; i < answer . size ( ) ; i ++ ) System . out . print ( answer . get ( i ) + " ▁ " ) ; } else System . out . print ( " No ▁ array ▁ " + " can ▁ be ▁ build " ) ; } public static void main ( String args [ ] ) { int n = 3 ; Integer input [ ] = { 2 , 5 , 6 , 7 , 11 } ; HashSet < Integer > GCD = new HashSet < Integer > ( Arrays . asList ( input ) ) ; ArrayList < Integer > arr = new ArrayList < Integer > ( ) ; for ( int v : GCD ) arr . add ( v ) ; compute ( arr , n ) ; } }

Accumulator variables: i
Iterator variables: i, v
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int binomialCoeff ( int n , int k ) { int [ ] [ ] C = new int [ n + 1 ] [ k + 1 ] ; int i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= Math . min ( i , k ) ; j ++ ) { if ( j == 0 j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } return C [ n ] [ k ] ; } static int k_Leaves ( int n , int k ) { int ans = ( binomialCoeff ( n , k ) * binomialCoeff ( n , k - 1 ) ) / n ; System . out . println ( " Number ▁ of ▁ trees ▁ " + " having ▁ 4 ▁ edges ▁ and ▁ exactly ▁ 2 ▁ " + " leaves ▁ : ▁ " + ans ) ; return 0 ; } static int numberOfNodes ( int n , int d ) { int ans = binomialCoeff ( 2 * n - 1 - d , n - 1 ) ; System . out . println ( " Number ▁ of ▁ nodes ▁ " + " of ▁ degree ▁ 1 ▁ in ▁ a ▁ tree ▁ having ▁ 4 ▁ " + " edges ▁ : ▁ " + ans ) ; return 0 ; } static int rootDegreeR ( int n , int r ) { int ans = r * binomialCoeff ( 2 * n - 1 - r , n - 1 ) ; ans = ans / n ; System . out . println ( " Number ▁ of ▁ trees ▁ " + " having ▁ 4 ▁ edges ▁ where ▁ root ▁ has " + " ▁ degree ▁ 2 ▁ : ▁ " + ans ) ; return 0 ; } public static void main ( String [ ] args ) { k_Leaves ( 3 , 2 ) ; numberOfNodes ( 3 , 1 ) ; rootDegreeR ( 3 , 2 ) ; } }

Index/key variables: i, j, k, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static int repUnitValue ( int n ) { if ( n % 2 == 0 n % 5 == 0 ) return 0 ; int rem = 1 ; int power = 1 ; int k = 1 ; while ( rem % n != 0 ) { k ++ ; power = power * 10 % n ; rem = ( rem + power ) % n ; } return k ; } public static void main ( String [ ] args ) { int n = 13 ; System . out . println ( repUnitValue ( n ) ) ; } }

Accumulator variables: k
Class/struct names: GFG
Java program:
class GFG { static int GCD ( int a , int b ) { return b == 0 ? a : GCD ( b , a % b ) ; } static boolean isSplittable ( int n , int m ) { int total_sum = ( n * ( n + 1 ) ) / 2 ; int sum_s1 = ( total_sum + m ) / 2 ; int sum_s2 = total_sum - sum_s1 ; if ( total_sum < m ) return false ; if ( sum_s1 + sum_s2 == total_sum && sum_s1 - sum_s2 == m ) return ( GCD ( sum_s1 , sum_s2 ) == 1 ) ; return false ; } public static void main ( String args [ ] ) { int n = 5 , m = 7 ; if ( isSplittable ( n , m ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean isPossibleToZero ( int a [ ] , int n ) { int num = 0 ; for ( int i = 0 ; i < n ; i ++ ) num = num * 10 + a [ i ] ; return ( num % 11 == 0 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 1 , 1 , 0 } ; int n = arr . length ; if ( isPossibleToZero ( arr , n ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

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