dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; import java . math . * ; public class GFG { int getMinNum ( int a , int b , int c ) { if ( c < a c > b ) { return c ; } int x = ( ( b / c ) * c ) + c ; return x ; } public static void main ( String args [ ] ) { int a = 2 ; int b = 4 ; int c = 4 ; GFG g = new GFG ( ) ; System . out . println ( g . getMinNum ( a , b , c ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static int countPairs ( int n ) { if ( n == 2 ) return 4 ; int num = ( ( n / 2 ) + 1 ) ; int max = n % num ; int count = n - max ; return count ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . println ( countPairs ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static boolean checkSub ( String sub , String s ) { int j = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) if ( sub . charAt ( j ) == s . charAt ( i ) ) j ++ ; return j == sub . length ( ) ; } static int getMultiple ( String s ) { for ( int i = 0 ; i < 1E3 ; i += 8 ) { if ( checkSub ( Integer . toString ( i ) , s ) ) return i ; } return - 1 ; } public static void main ( String [ ] args ) { String s = "3454" ; System . out . println ( getMultiple ( s ) ) ; } }

Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String getResult ( int n ) { String st = Integer . toString ( n ) ; for ( int i = 0 ; i < st . length ( ) ; i ++ ) { int d = st . charAt ( i ) - 48 ; if ( n % d == 0 ) { return " Yes " ; } } return " No " ; } public static void main ( String [ ] args ) { int n = 9876543 ; System . out . println ( getResult ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { float sum ( float n ) { if ( n < 2 ) return 1 ; else return 1 / n + ( sum ( n - 1 ) ) ; } public static void main ( String args [ ] ) { GFG g = new GFG ( ) ; System . out . println ( g . sum ( 8 ) ) ; System . out . print ( g . sum ( 10 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static ArrayList < Integer > findingValues ( int m , int n , int mth , int nth ) { int d = ( Math . abs ( mth - nth ) ) / Math . abs ( ( m - 1 ) - ( n - 1 ) ) ; int a = mth - ( ( m - 1 ) * d ) ; ArrayList < Integer > res = new ArrayList < Integer > ( ) ; res . add ( a ) ; res . add ( d ) ; return res ; } static int findSum ( int m , int n , int mth , int nth , int p ) { ArrayList < Integer > ad = findingValues ( m , n , mth , nth ) ; int a = ad . get ( 0 ) ; int d = ad . get ( 1 ) ; int sum = ( p * ( 2 * a + ( p - 1 ) * d ) ) / 2 ; return sum ; } public static void main ( String [ ] args ) { int m = 6 , n = 10 , mTerm = 12 , nTerm = 20 , p = 5 ; System . out . println ( findSum ( m , n , mTerm , nTerm , p ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . Math ; class GfG { static void powerfulIntegers ( int x , int y , int bound ) { Set < Integer > s = new HashSet < > ( ) ; ArrayList < Integer > powersOfY = new ArrayList < > ( ) ; int i ; powersOfY . add ( 1 ) ; for ( i = y ; i < bound && y != 1 ; i = i * y ) powersOfY . add ( i ) ; i = 0 ; while ( true ) { int xPowI = ( int ) Math . pow ( ( double ) x , ( double ) i ) ; for ( int j = 0 ; j < powersOfY . size ( ) ; ++ j ) { int num = xPowI + powersOfY . get ( j ) ; if ( num <= bound ) s . add ( num ) ; else break ; } if ( xPowI >= bound x == 1 ) break ; i ++ ; } Iterator itr = s . iterator ( ) ; while ( itr . hasNext ( ) ) { System . out . print ( itr . next ( ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int x = 2 , y = 1 , bound = 10 ; powerfulIntegers ( x , y , bound ) ; } }

Accumulator variables: i
Iterator variables: i, j
Class/struct names: GfG
Java program:
class GFG { static void candies ( int n , int k ) { int count = 0 ; int ind = 1 ; int [ ] arr = new int [ k ] ; for ( int i = 0 ; i < k ; i ++ ) arr [ i ] = 0 ; while ( n > 0 ) { int f1 = ( ind - 1 ) * k ; int f2 = ind * k ; int sum1 = ( f1 * ( f1 + 1 ) ) / 2 ; int sum2 = ( f2 * ( f2 + 1 ) ) / 2 ; int res = sum2 - sum1 ; if ( res <= n ) { count ++ ; n -= res ; ind ++ ; } { int i = 0 ; int term = ( ( ind - 1 ) * k ) + 1 ; while ( n > 0 ) { if ( term <= n ) { arr [ i ++ ] = term ; n -= term ; term ++ ; } else { arr [ i ++ ] = n ; n = 0 ; } } } } for ( int i = 0 ; i < k ; i ++ ) arr [ i ] += ( count * ( i + 1 ) ) + ( k * ( count * ( count - 1 ) ) / 2 ) ; for ( int i = 0 ; i < k ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int n = 10 , k = 3 ; candies ( n , k ) ; } }

Index/key variables: i, k
Accumulator variables: count, i, ind, n, term
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void candies ( int n , int k ) { int count = 0 ; int ind = 1 ; int [ ] arr = new int [ k ] ; for ( int i = 0 ; i < k ; i ++ ) arr [ i ] = 0 ; int low = 0 , high = n ; while ( low <= high ) { int mid = ( low + high ) >> 1 ; int sum = ( mid * ( mid + 1 ) ) >> 1 ; if ( sum <= n ) { count = mid / k ; low = mid + 1 ; } else { high = mid - 1 ; } } int last = ( count * k ) ; n -= ( last * ( last + 1 ) ) / 2 ; int j = 0 ; int term = ( count * k ) + 1 ; while ( n > 0 ) { if ( term <= n ) { arr [ j ++ ] = term ; n -= term ; term ++ ; } else { arr [ j ] += n ; n = 0 ; } } for ( int i = 0 ; i < k ; i ++ ) arr [ i ] += ( count * ( i + 1 ) ) + ( k * ( count * ( count - 1 ) ) / 2 ) ; for ( int i = 0 ; i < k ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int n = 7 , k = 4 ; candies ( n , k ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, n, term
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; public class GFG { static int printSmallest ( int a [ ] ) { int sum , sum1 ; Arrays . sort ( a ) ; int i , j , k , num ; for ( i = 0 ; i < 3 ; i ++ ) { if ( a [ i ] % 3 == 0 ) { return a [ i ] ; } } for ( i = 0 ; i < 3 ; i ++ ) { for ( j = 0 ; j < 3 ; j ++ ) { num = ( a [ i ] * 10 ) + a [ j ] ; if ( num % 3 == 0 ) { return num ; } } } return a [ 0 ] * 100 + a [ 0 ] * 10 + a [ 0 ] ; } public static void main ( String [ ] args ) { int arr [ ] = { 7 , 7 , 1 } ; System . out . println ( printSmallest ( arr ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class GFG { static void updateMatrix ( int n , int q [ ] [ ] , int mat [ ] [ ] ) { int i , j ; for ( i = 0 ; i < q . length ; i ++ ) { int X1 = q [ i ] [ 0 ] ; int Y1 = q [ i ] [ 1 ] ; int X2 = q [ i ] [ 2 ] ; int Y2 = q [ i ] [ 3 ] ; mat [ X1 ] [ Y1 ] ++ ; if ( Y2 + 1 < n ) mat [ X2 ] [ Y2 + 1 ] -- ; else if ( X2 + 1 < n ) mat [ X2 + 1 ] [ 0 ] -- ; } int sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < n ; j ++ ) { sum += mat [ i ] [ j ] ; System . out . print ( sum + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int n = 5 ; int mat [ ] [ ] = new int [ n ] [ n ] ; int q [ ] [ ] = { { 0 , 0 , 1 , 2 } , { 1 , 2 , 3 , 4 } , { 1 , 4 , 3 , 4 } } ; updateMatrix ( n , q , mat ) ; } }

Index/key variables: X1, X2, Y1, i, j, n
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printArr ( float arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } static void replaceMax ( float arr [ ] , int n ) { float max = arr [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > max ) max = arr [ i ] ; } float min = arr [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < min ) min = arr [ i ] ; } float range = max - min ; float coeffOfRange = range / ( max + min ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == max ) { arr [ i ] = coeffOfRange ; break ; } } printArr ( arr , n ) ; } public static void main ( String args [ ] ) { float arr [ ] = { 15 , 16 , 10 , 9 , 6 , 7 , 17 } ; int n = arr . length ; replaceMax ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class solution { static void divide ( int a , int b ) { for ( int i = 2 ; i <= Math . min ( a , b ) ; i ++ ) { while ( a % i == 0 && b % i == 0 ) { a = a / i ; b = b / i ; } } System . out . println ( " A ▁ = ▁ " + a + " , ▁ B ▁ = ▁ " + b ) ; } public static void main ( String args [ ] ) { int A = 10 , B = 15 ; divide ( A , B ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: solution
Java program:
class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static void commDiv ( int a , int b ) { int n = gcd ( a , b ) ; a = a / n ; b = b / n ; System . out . println ( " A ▁ = ▁ " + a + " , ▁ B ▁ = ▁ " + b ) ; } public static void main ( String [ ] args ) { int a = 10 , b = 15 ; commDiv ( a , b ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int minAbsDiff ( int n ) { int left = 1 << ( ( int ) Math . floor ( Math . log ( n ) / Math . log ( 2 ) ) ) ; int right = left * 2 ; return Math . min ( ( n - left ) , ( right - n ) ) ; } public static void main ( String [ ] args ) { int n = 15 ; System . out . println ( minAbsDiff ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . text . DecimalFormat ; class solution { static double find_probability ( double p , double q , double r , double s ) { double t = ( 1 - p / q ) * ( 1 - r / s ) ; double ans = ( p / q ) / ( 1 - t ) ; return ans ; } public static void main ( String args [ ] ) { double p = 1 , q = 2 , r = 1 , s = 2 ; DecimalFormat dec = new DecimalFormat ( " # 0.000000000" ) ; System . out . println ( dec . format ( find_probability ( p , q , r , s ) ) ) ; } }

Class/struct names: solution
Java program:
import java . util . Arrays ; public class GfG { public static void FindAllElements ( int n , int k ) { int sum = k ; int [ ] A = new int [ k ] ; Arrays . fill ( A , 0 , k , 1 ) ; for ( int i = k - 1 ; i >= 0 ; -- i ) { while ( sum + A [ i ] <= n ) { sum += A [ i ] ; A [ i ] *= 2 ; } } if ( sum != n ) { System . out . print ( " Impossible " ) ; } else { for ( int i = 0 ; i < k ; ++ i ) System . out . print ( A [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int n = 12 ; int k = 6 ; FindAllElements ( n , k ) ; } }

Index/key variables: i, k
Accumulator variables: sum
Iterator variables: i
Class/struct names: GfG
Java program:
public class GfG { public static int removeZero ( int n ) { int res = 0 ; int d = 1 ; while ( n > 0 ) { if ( n % 10 != 0 ) { res += ( n % 10 ) * d ; d *= 10 ; } n /= 10 ; } return res ; } public static boolean isEqual ( int a , int b ) { if ( removeZero ( a ) + removeZero ( b ) == removeZero ( a + b ) ) return true ; return false ; } public static void main ( String [ ] args ) { int a = 105 , b = 106 ; if ( isEqual ( a , b ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: d, n, res
Class/struct names: GfG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class Geeks { public static void sumArray ( int arr [ ] , int n ) { int leftSum [ ] = new int [ n ] ; int rightSum [ ] = new int [ n ] ; int Sum [ ] = new int [ n ] ; int i = 0 , j = 0 ; leftSum [ 0 ] = 0 ; rightSum [ n - 1 ] = 0 ; for ( i = 1 ; i < n ; i ++ ) leftSum [ i ] = arr [ i - 1 ] + leftSum [ i - 1 ] ; for ( j = n - 2 ; j >= 0 ; j -- ) rightSum [ j ] = arr [ j + 1 ] + rightSum [ j + 1 ] ; for ( i = 0 ; i < n ; i ++ ) Sum [ i ] = leftSum [ i ] + rightSum [ i ] ; for ( i = 0 ; i < n ; i ++ ) System . out . print ( Sum [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 6 , 4 , 8 , 9 } ; int n = arr . length ; sumArray ( arr , n ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Geeks
Java program:
import java . util . * ; class solution { static int minimumX ( int n , int k ) { int mini = Integer . MAX_VALUE ; for ( int i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { int fir = i ; int sec = n / i ; int num1 = fir * k + sec ; int res = ( num1 / k ) * ( num1 % k ) ; if ( res == n ) mini = Math . min ( num1 , mini ) ; int num2 = sec * k + fir ; res = ( num2 / k ) * ( num2 % k ) ; if ( res == n ) mini = Math . min ( num2 , mini ) ; } } return mini ; } public static void main ( String args [ ] ) { int n = 4 , k = 6 ; System . out . println ( minimumX ( n , k ) ) ; n = 5 ; k = 5 ; System . out . println ( minimumX ( n , k ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: solution
Java program:
class Solution { static int minimumX ( int n , int k ) { int ans = Integer . MAX_VALUE ; for ( int rem = k - 1 ; rem > 0 ; rem -- ) { if ( n % rem == 0 ) ans = Math . min ( ans , rem + ( n / rem ) * k ) ; } return ans ; } public static void main ( String args [ ] ) { int n = 4 , k = 6 ; System . out . println ( minimumX ( n , k ) ) ; n = 5 ; k = 5 ; System . out . println ( minimumX ( n , k ) ) ; } }

Accumulator variables: rem
Iterator variables: rem
Class/struct names: Solution
Java program:
import java . util . * ; class GFG { static int getHermiteNumber ( int n ) { if ( n == 0 ) return 1 ; else if ( n == 1 ) return 1 ; else return - 2 * ( n - 1 ) * getHermiteNumber ( n - 2 ) ; } public static void main ( String [ ] args ) { int n = 6 ; System . out . println ( getHermiteNumber ( n ) ) ; } }

Class/struct names: GFG
Java program:
public class GFG { static void find ( int n ) { int b = n ; int a = b * ( n - 1 ) ; if ( a * b > n && a / b < n ) { System . out . print ( " a ▁ = ▁ " + a + " , ▁ b ▁ = ▁ " + b ) ; } else System . out . println ( - 1 ) ; } public static void main ( String [ ] args ) { int n = 10 ; find ( n ) ; } }

Class/struct names: GFG
Java program:
class GFG { static boolean isPerfect ( int N ) { if ( ( Math . sqrt ( N ) - Math . floor ( Math . sqrt ( N ) ) ) != 0 ) return false ; return true ; } static void getClosestPerfectSquare ( int N ) { if ( isPerfect ( N ) ) { System . out . println ( N + " ▁ " + "0" ) ; return ; } int aboveN = - 1 , belowN = - 1 ; int n1 ; n1 = N + 1 ; while ( true ) { if ( isPerfect ( n1 ) ) { aboveN = n1 ; break ; } else n1 ++ ; } n1 = N - 1 ; while ( true ) { if ( isPerfect ( n1 ) ) { belowN = n1 ; break ; } else n1 -- ; } int diff1 = aboveN - N ; int diff2 = N - belowN ; if ( diff1 > diff2 ) System . out . println ( belowN + " ▁ " + diff2 ) ; else System . out . println ( aboveN + " ▁ " + diff1 ) ; } public static void main ( String args [ ] ) { int N = 1500 ; getClosestPerfectSquare ( N ) ; } }

Accumulator variables: n1
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int den3 , num3 ; static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static void lowest ( ) { int common_factor = gcd ( num3 , den3 ) ; den3 = den3 / common_factor ; num3 = num3 / common_factor ; } static void addFraction ( int num1 , int den1 , int num2 , int den2 ) { den3 = gcd ( den1 , den2 ) ; den3 = ( den1 * den2 ) / den3 ; num3 = ( num1 ) * ( den3 / den1 ) + ( num2 ) * ( den3 / den2 ) ; lowest ( ) ; } public static void main ( String [ ] args ) { int num1 = 1 , den1 = 500 , num2 = 2 , den2 = 1500 ; addFraction ( num1 , den1 , num2 , den2 ) ; System . out . printf ( "%d/%d + %d/%d is equal to %d/%dNEW_LINE", num1, den1, num2, den2, num3, den3); } }

Class/struct names: GFG
Java program:
public class GFG { static int findLargestDivisor ( int n ) { for ( int i = 2 ; i < Math . sqrt ( n ) + 1 ; i ++ ) { while ( n % ( i * i ) == 0 ) { n = n / i ; } } return n ; } public static void main ( String args [ ] ) { int n = 12 ; System . out . println ( findLargestDivisor ( n ) ) ; n = 97 ; System . out . println ( findLargestDivisor ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static boolean isTriPerfect ( int n ) { int sum = 1 + n ; int i = 2 ; while ( i * i <= n ) { if ( n % i == 0 ) { if ( n / i == i ) sum = sum + i ; else sum = sum + i + n / i ; } i += 1 ; } if ( sum == 3 * n & n != 1 ) return true ; else return false ; } public static void main ( String [ ] args ) { int n = 120 ; if ( isTriPerfect ( n ) ) System . out . println ( n + " ▁ is ▁ a ▁ Triperfect ▁ number " ) ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
public class GFG { static int sum ( int N , int X , int Y ) { int S1 , S2 , S3 ; S1 = ( ( N / X ) ) * ( 2 * X + ( N / X - 1 ) * X ) / 2 ; S2 = ( ( N / Y ) ) * ( 2 * Y + ( N / Y - 1 ) * Y ) / 2 ; S3 = ( ( N / ( X * Y ) ) ) * ( 2 * ( X * Y ) + ( N / ( X * Y ) - 1 ) * ( X * Y ) ) / 2 ; return S1 + S2 - S3 ; } public static void main ( String [ ] args ) { int N = 14 ; int X = 3 , Y = 5 ; System . out . println ( sum ( N , X , Y ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int findTwoThreePrime ( int l , int r ) { if ( l == 1 ) l ++ ; int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { int num = i ; while ( num % 2 == 0 ) num /= 2 ; while ( num % 3 == 0 ) num /= 3 ; if ( num == 1 ) count ++ ; } return count ; } public static void main ( String [ ] args ) { int l = 1 , r = 10 ; System . out . println ( findTwoThreePrime ( l , r ) ) ; } }

Accumulator variables: count, i, l, num
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String getNumber ( String s ) { int number_of_digits = s . length ( ) ; int freq [ ] = new int [ 10 ] ; for ( int i = 0 ; i < number_of_digits ; i ++ ) { if ( s . charAt ( i ) == '1' || s . charAt ( i ) == '2' || s . charAt ( i ) == '3' || s . charAt ( i ) == '5' || s . charAt ( i ) == '7' ) { freq [ s . charAt ( i ) - 48 ] += 1 ; } if ( s . charAt ( i ) == '4' ) { freq [ 2 ] += 2 ; freq [ 3 ] ++ ; } if ( s . charAt ( i ) == '6' ) { freq [ 5 ] ++ ; freq [ 3 ] ++ ; } if ( s . charAt ( i ) == '8' ) { freq [ 7 ] ++ ; freq [ 2 ] += 3 ; } if ( s . charAt ( i ) == '9' ) { freq [ 7 ] ++ ; freq [ 3 ] += 2 ; freq [ 2 ] ++ ; } } String t = " " ; if ( freq [ 1 ] == number_of_digits || freq [ 0 ] == number_of_digits || ( freq [ 0 ] + freq [ 1 ] ) == number_of_digits ) { return s ; } else { for ( int i = 9 ; i >= 2 ; i -- ) { int ctr = freq [ i ] ; while ( ( ctr -- ) > 0 ) { t += ( char ) ( i + 48 ) ; } } return t ; } } public static void main ( String [ ] args ) { String s = "1280" ; System . out . println ( getNumber ( s ) ) ; } }

Index/key variables: i
Accumulator variables: ctr, i, t
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static int reversDigits ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static void icanobifNumbers ( int N ) { int first = 0 , second = 1 ; if ( N == 1 ) System . out . print ( first ) ; else if ( N == 2 ) System . out . print ( first + " ▁ " + second ) ; else { System . out . print ( first + " ▁ " + second + " ▁ " ) ; for ( int i = 3 ; i <= N ; i ++ ) { int x = reversDigits ( first ) ; int y = reversDigits ( second ) ; System . out . print ( x + y + " ▁ " ) ; int temp = second ; second = x + y ; first = temp ; } } } public static void main ( String [ ] args ) { int N = 12 ; icanobifNumbers ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int addNDigits ( int a , int b , int n ) { int num = a ; for ( int i = 0 ; i <= 9 ; i ++ ) { int tmp = a * 10 + i ; if ( tmp % b == 0 ) { a = tmp ; break ; } } if ( num == a ) return - 1 ; for ( int j = 0 ; j < n - 1 ; j ++ ) a *= 10 ; return a ; } public static void main ( String [ ] args ) { int a = 5 , b = 3 , n = 3 ; System . out . print ( addNDigits ( a , b , n ) ) ; } }

Accumulator variables: a, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class Solution { static int Triplets ( int n ) { int ans = 0 ; for ( int i = 1 ; i <= n ; ++ i ) { for ( int j = i ; j <= n ; ++ j ) { int x = i * i + j * j ; int y = ( int ) Math . sqrt ( x ) ; if ( y * y == x && y <= n ) ++ ans ; } } return ans ; } public static void main ( String args [ ] ) { int n = 10 ; System . out . println ( Triplets ( n ) ) ; } }

Iterator variables: i, j
Class/struct names: Solution
Java program:
import java . io . * ; class GFG { static int solve ( int n , int base ) { int sum = 0 ; while ( n > 0 ) { int remainder = n % base ; sum += remainder ; n = n / base ; } return sum ; } static void SumsOfDigits ( int n ) { int sum = 0 ; for ( int base = 2 ; base <= n / 2 ; ++ base ) sum += solve ( n , base ) ; System . out . println ( sum ) ; } public static void main ( String [ ] args ) { int n = 8 ; SumsOfDigits ( n ) ; } }

Accumulator variables: sum
Iterator variables: base
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean checkPerfectcube ( int n ) { int d = ( int ) Math . cbrt ( n ) ; if ( d * d * d == n ) return true ; return false ; } static int largestNonPerfectcubeNumber ( int [ ] a , int n ) { int maxi = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! checkPerfectcube ( a [ i ] ) ) maxi = Math . max ( a [ i ] , maxi ) ; } return maxi ; } public static void main ( String [ ] args ) { int a [ ] = { 16 , 64 , 25 , 2 , 3 , 10 } ; int n = a . length ; System . out . print ( largestNonPerfectcubeNumber ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class solution { static void checkIfPossibleRec ( int x , int a , int b , boolean isPossible [ ] , int n ) { if ( x > n ) return ; if ( isPossible [ x ] ) return ; isPossible [ x ] = true ; checkIfPossibleRec ( x + a , a , b , isPossible , n ) ; checkIfPossibleRec ( x + b , a , b , isPossible , n ) ; } static boolean checkPossible ( int n , int a , int b ) { boolean isPossible [ ] = new boolean [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) isPossible [ i ] = false ; checkIfPossibleRec ( 0 , a , b , isPossible , n ) ; return isPossible [ n ] ; } public static void main ( String args [ ] ) { int a = 3 , b = 7 , n = 8 ; if ( checkPossible ( a , b , n ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Index/key variables: i, n, x
Accumulator variables: i
Iterator variables: i
Class/struct names: solution
Java program:
import java . io . * ; class GFG { static int sumOdd ( int n ) { int terms = ( n + 1 ) / 2 ; int sum = terms * terms ; return sum ; } static int suminRange ( int l , int r ) { return sumOdd ( r ) - sumOdd ( l - 1 ) ; } public static void main ( String [ ] args ) { int l = 2 , r = 5 ; System . out . print ( " Sum ▁ of ▁ odd ▁ natural ▁ numbers ▁ from ▁ L ▁ to ▁ R ▁ is ▁ " + suminRange ( l , r ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int sumcommDiv ( int a , int b ) { int n = gcd ( a , b ) ; int sum = 0 ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) sum += i ; else sum += ( n / i ) + i ; } } return sum ; } public static void main ( String [ ] args ) { int a = 10 , b = 15 ; System . out . println ( " Sum ▁ = ▁ " + sumcommDiv ( a , b ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String checkNumber ( int N ) { int temp = N ; while ( temp > 0 ) { if ( temp % 1000 == 144 ) temp /= 1000 ; else if ( temp % 100 == 14 ) temp /= 100 ; else if ( temp % 10 == 1 ) temp /= 10 ; else { return " NO " ; } } return " YES " ; } public static void main ( String [ ] args ) { int N = 1414 ; System . out . println ( checkNumber ( N ) ) ; } }

Accumulator variables: temp
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int getResult ( int n ) { if ( ( n & 1 ) > 0 ) return 1 ; return - 1 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( getResult ( n ) ) ; } }

Class/struct names: GFG