dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function divisorsSame ( n ) { let even_div = 0 , odd_div = 0 ; for ( let i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( Math . floor ( n / i ) == i ) { if ( i % 2 == 0 ) { even_div ++ ; } else { odd_div ++ ; } } else { if ( i % 2 == 0 ) { even_div ++ ; } else { odd_div ++ ; } if ( Math . floor ( n / i ) % 2 == 0 ) { even_div ++ ; } else { odd_div ++ ; } } } } return ( even_div == odd_div ) ; } let N = 6 ; if ( divisorsSame ( N ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Accumulator variables: even_div, i, odd_div
Iterator variables: i
Javascript program:
function isPrime ( n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( let i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } function isBalancedPrime ( n ) { if ( ! isPrime ( n ) n == 2 ) return false ; let previous_prime = n - 1 ; let next_prime = n + 1 ; while ( ! isPrime ( next_prime ) ) next_prime ++ ; while ( ! isPrime ( previous_prime ) ) previous_prime -- ; let mean = ( previous_prime + next_prime ) / 2 ; if ( n == mean ) return true ; else return false ; } let n = 53 ; if ( isBalancedPrime ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: next_prime, previous_prime
Iterator variables: i
Javascript program:
let N = 100001 ; let adj = new Array ( N ) ; let a = new Array ( N ) ; let ans = new Array ( N ) ; function hasOddNumberOfDivisors ( n ) { if ( Math . sqrt ( n ) == parseInt ( Math . sqrt ( n ) , 10 ) ) return true ; return false ; } function dfs ( node , parent ) { let count = 0 ; for ( let i = 0 ; i < adj [ node ] . length ; i ++ ) { if ( adj [ node ] [ i ] != parent ) { count += dfs ( adj [ node ] [ i ] , node ) ; } } if ( hasOddNumberOfDivisors ( a [ node ] ) ) ++ count ; ans [ node ] = count ; return count ; } let n = 5 ; let q = [ 4 , 1 , 5 , 3 ] ; for ( let i = 0 ; i < adj . length ; i ++ ) adj [ i ] = [ ] ; adj [ 1 ] . push ( 2 ) ; adj [ 2 ] . push ( 1 ) ; adj [ 2 ] . push ( 3 ) ; adj [ 3 ] . push ( 2 ) ; adj [ 3 ] . push ( 4 ) ; adj [ 4 ] . push ( 3 ) ; adj [ 1 ] . push ( 5 ) ; adj [ 5 ] . push ( 1 ) ; a [ 1 ] = 4 ; a [ 2 ] = 9 ; a [ 3 ] = 14 ; a [ 4 ] = 100 ; a [ 5 ] = 5 ; dfs ( 1 , - 1 ) ; for ( let i = 0 ; i < q . length ; i ++ ) { document . write ( ans [ q [ i ] ] + " " ) ; }

Index/key variables: i, node
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function lowerBound ( array , length , value ) { var low = 0 ; var high = length ; while ( low < high ) { var mid = parseInt ( ( low + high ) / 2 ) ; if ( value <= array [ mid ] ) { high = mid ; } else { low = mid + 1 ; } } return low ; } function costCalculation ( current , arr , n , pref , a , r , minimum ) { var index = lowerBound ( arr , arr . length , current ) ; var left = index * current - pref [ index ] ; var right = pref [ n ] - pref [ index ] - ( n - index ) * current ; var res = Math . min ( left , right ) ; left -= res ; right -= res ; var total = res * minimum ; total += left * a ; total += right * r ; return total ; } function solve ( arr , n , a , r , m ) { arr . sort ( ) ; var minimum = Math . min ( a + r , m ) ; var pref = Array ( n + 1 ) . fill ( 0 ) ; for ( i = 0 ; i < n ; i ++ ) pref [ i + 1 ] = pref [ i ] + arr [ i ] ; var ans = 10000 ; for ( i = 0 ; i < n ; i ++ ) ans = Math . min ( ans , costCalculation ( arr [ i ] , arr , n , pref , a , r , minimum ) ) ; ans = Math . min ( ans , costCalculation ( pref [ n ] / n , arr , n , pref , a , r , minimum ) ) ; ans = Math . min ( ans , costCalculation ( pref [ n ] / n + 1 , arr , n , pref , a , r , minimum ) ) ; document . write ( ans ) ; } var arr = [ 5 , 5 , 3 , 6 , 5 ] ; var A = 1 , R = 2 , M = 4 ; var size = arr . length ; solve ( arr , size , A , R , M ) ;

Index/key variables: i, index, mid, n
Accumulator variables: i, left, right, total
Iterator variables: i
Javascript program:
function countBinaries ( N ) { let ctr = 1 ; let ans = 0 ; while ( N > 0 ) { if ( N % 10 == 1 ) { ans += Math . pow ( 2 , ctr - 1 ) ; } else if ( N % 10 > 1 ) { ans = Math . pow ( 2 , ctr ) - 1 ; } ctr ++ ; N /= 10 ; } return ans ; } let N = 20 ; document . write ( countBinaries ( N ) ) ;

Accumulator variables: N, ans, ctr
Javascript program:
function countBinaries ( N ) { let powersOfTwo = [ ] ; powersOfTwo . push ( 1 ) ; for ( let i = 1 ; i < 11 ; i ++ ) { powersOfTwo . push ( powersOfTwo [ i - 1 ] * 2 ) ; } let ctr = 1 ; let ans = 0 ; while ( N > 0 ) { if ( N % 10 == 1 ) { ans += powersOfTwo [ ctr - 1 ] ; } else if ( N % 10 > 1 ) { ans = powersOfTwo [ ctr ] - 1 ; } ctr ++ ; N /= 10 ; } return ans ; } let N = 20 ; document . write ( countBinaries ( N ) ) ;

Index/key variables: ctr
Accumulator variables: N, ans, ctr, i
Iterator variables: i
Javascript program:
function center_heptagonal_num ( n ) { return ( 7 * n * n - 7 * n + 2 ) / 2 ; } function sum_center_heptagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += center_heptagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_center_heptagonal_num ( n ) ) ;

Accumulator variables: i, summ
Iterator variables: i
Javascript program:
function Centered_Dodecagonal_num ( n ) { return 6 * n * ( n - 1 ) + 1 ; } function sum_Centered_Dodecagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += Centered_Dodecagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_Centered_Dodecagonal_num ( n ) ) ;

Accumulator variables: i, summ
Iterator variables: i
Javascript program:
function center_Octagonal_num ( n ) { return ( 4 * n * n - 4 * n + 1 ) ; } function sum_center_Octagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += center_Octagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_center_Octagonal_num ( n ) ) ;

Accumulator variables: i, summ
Iterator variables: i
Javascript program:
function Centered_decagonal_num ( n ) { return ( 5 * n * n - 5 * n + 1 ) ; } function sum_Centered_decagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += Centered_decagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_Centered_decagonal_num ( n ) ) ;

Accumulator variables: i, summ
Iterator variables: i
Javascript program:
function center_octadecagon_num ( n ) { return ( 9 * n * n - 9 * n + 1 ) ; } function sum_center_octadecagon_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += center_octadecagon_num ( i ) ; } return summ ; } let n = 3 ; document . write ( sum_center_octadecagon_num ( n ) ) ;

Accumulator variables: i, summ
Iterator variables: i
Javascript program:
function Centered_Pentadecagonal_num ( n ) { return ( 15 * n * n - 15 * n + 2 ) / 2 ; } function sum_Centered_Pentadecagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += Centered_Pentadecagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_Centered_Pentadecagonal_num ( n ) ) ;

Accumulator variables: i, summ
Iterator variables: i
Javascript program:
function Icosagonal_num ( n ) { return ( 18 * n * n - 16 * n ) / 2 ; } function sum_Icosagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i <= n ; i ++ ) { summ += Icosagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_Icosagonal_num ( n ) ) ;

Accumulator variables: i, summ
Iterator variables: i
Javascript program:
function Centered_Pentagonal_num ( n ) { return ( 5 * n * n - 5 * n + 2 ) / 2 ; } function sum_Centered_Pentagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += Centered_Pentagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_Centered_Pentagonal_num ( n ) ) ;

Accumulator variables: i, summ
Iterator variables: i
Javascript program:
function Centered_tridecagonal_num ( n ) { return ( 13 * n * ( n - 1 ) + 2 ) / 2 ; } function sum_Centered_tridecagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i <= n ; i ++ ) { summ += Centered_tridecagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_Centered_tridecagonal_num ( n ) ) ;

Accumulator variables: i, summ
Iterator variables: i
Javascript program:
var Prime = Array ( 100 ) . fill ( true ) ; function computePrime ( N ) { var i , j ; Prime [ 0 ] = Prime [ 1 ] = false ; for ( i = 2 ; i * i <= N ; i ++ ) { if ( Prime [ i ] ) { for ( j = i * i ; j < N ; j += i ) { Prime [ j ] = false ; } } } } function countSexyPairs ( arr , n ) { var maxE = Math . max . apply ( Math , arr ) ; computePrime ( maxE ) ; var count = 0 ; var freq = Array ( maxE + 1 ) . fill ( 0 ) ; for ( i = 0 ; i < n ; i ++ ) { freq [ arr [ i ] ] ++ ; } arr . sort ( ) ; for ( i = 0 ; i < n ; i ++ ) { if ( Prime [ arr [ i ] ] ) { if ( freq [ arr [ i ] + 6 ] > 0 && Prime [ arr [ i ] + 6 ] ) { count ++ ; } } } return count ; } var arr = [ 6 , 7 , 5 , 11 , 13 ] ; var n = arr . length ; document . write ( countSexyPairs ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function isAutoBiographyNum ( number ) { let count = 0 , position , size , digit ; let NUM ; NUM = number . toString ( ) ; size = NUM . length ; for ( let i = 0 ; i < size ; i ++ ) { position = NUM [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; count = 0 ; for ( let j = 0 ; j < size ; j ++ ) { digit = NUM [ j ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; if ( digit == i ) count ++ ; } if ( position != count ) return false ; } return true ; } function checkArray ( arr , n ) { let current_length = 0 ; let max_length = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( isAutoBiographyNum ( arr [ i ] ) ) current_length ++ ; else current_length = 0 ; max_length = Math . max ( max_length , current_length ) ; } return max_length ; } let arr = [ 21200 , 1 , 1303 , 1210 , 2020 ] ; let n = arr . length ; document . write ( checkArray ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: count, current_length, i, j
Iterator variables: i, j
Javascript program:
class pair { constructor ( first , second ) { this . first = first ; this . second = second ; } } function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } function sumOfSquares ( n , vp ) { for ( let i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { let h = n - i * i , h1 = Math . floor ( Math . sqrt ( h ) ) ; if ( h1 * h1 == h ) { let a = Math . max ( h1 , i ) , b = Math . min ( h1 , i ) ; if ( vp . length == 1 && a != vp [ 0 ] . first ) vp . push ( new pair ( a , b ) ) ; if ( vp . length == 0 ) vp . push ( new pair ( a , b ) ) ; if ( vp . length == 2 ) return ; } } } function findFactors ( n ) { let vp = [ ] ; sumOfSquares ( n , vp ) ; if ( vp . length != 2 ) document . write ( " " ) ; let a , b , c , d ; a = vp [ 0 ] . first ; b = vp [ 0 ] . second ; c = vp [ 1 ] . first ; d = vp [ 1 ] . second ; if ( a < c ) { let t = a ; a = c ; c = t ; t = b ; b = d ; d = t ; } let k , h , l , m ; k = __gcd ( a - c , d - b ) ; h = __gcd ( a + c , d + b ) ; l = ( a - c ) / k ; m = ( d - b ) / k ; document . write ( " " + a + " " + ( a - c ) + " " + k + " " ) ; document . write ( " " + b + " " + ( a + c ) + " " + h + " " ) ; document . write ( " " + c + " " + ( d - b ) + " " + l + " " ) ; document . write ( " " + d + " " + ( d + b ) + " " + m + " " ) ; if ( k % 2 == 0 && h % 2 == 0 ) { k = k / 2 ; h = h / 2 ; document . write ( " " + ( ( k ) * ( k ) + ( h ) * ( h ) ) + " " + ( l * l + m * m ) + " " ) ; } else { l = l / 2 ; m = m / 2 ; document . write ( " " + ( ( l ) * ( l ) + ( m ) * ( m ) ) + " " + ( k * k + h * h ) + " " ) ; } } let n = 100000 ; findFactors ( n ) ;

Accumulator variables: i
Iterator variables: i
Class/struct names: pair
Javascript program:
let MAX = 100000 ; let graph = [ ] for ( let i = 0 ; i < MAX + 1 ; i ++ ) { graph . push ( [ ] ) } let Prime = new Array ( MAX + 1 ) . fill ( true ) ; let height = new Array ( MAX + 1 ) ; function SieveOfEratosthenes ( ) { let i , j ; Prime [ 0 ] = Prime [ 1 ] = false ; for ( i = 2 ; i * i <= MAX ; i ++ ) { if ( Prime [ i ] ) { for ( j = 2 * i ; j < MAX ; j += i ) { Prime [ j ] = false ; } } } } function dfs ( node , parent , h ) { height [ node ] = h ; for ( let to of graph [ node ] ) { if ( to == parent ) continue ; dfs ( to , node , h + 1 ) ; } } function primeHeightNode ( N ) { SieveOfEratosthenes ( ) ; for ( let i = 1 ; i <= N ; i ++ ) { if ( Prime [ height [ i ] ] ) { document . write ( i + " " ) ; } } } let N = 5 ; graph [ 1 ] . push ( 2 ) ; graph [ 1 ] . push ( 3 ) ; graph [ 2 ] . push ( 4 ) ; graph [ 2 ] . push ( 5 ) ; dfs ( 1 , 1 , 0 ) ; primeHeightNode ( N ) ;

Index/key variables: i, j, node
Accumulator variables: i, j
Iterator variables: i, j, to
Javascript program:
function reverse ( a ) { let rev = 0 ; while ( a != 0 ) { let r = a % 10 ; rev = rev * 10 + r ; a = parseInt ( a / 10 , 10 ) ; } return ( rev ) ; } function prime ( a ) { let k = 0 ; for ( let i = 2 ; i < a ; i ++ ) { if ( a % i == 0 ) { k = 1 ; break ; } } if ( k == 1 ) { return ( 0 ) ; } else { return ( 1 ) ; } } function adam ( a ) { let r1 = reverse ( a ) ; let s1 = a * a ; let s2 = r1 * r1 ; let r2 = reverse ( s2 ) ; if ( s1 == r2 ) { return ( 1 ) ; } else { return ( 0 ) ; } } function find ( m , n ) { if ( m > n ) { document . write ( " " + " " ) ; } else { let c = 0 ; for ( let i = m ; i <= n ; i ++ ) { let l = prime ( i ) ; let k = adam ( i ) ; if ( ( l == 1 ) && ( k == 1 ) ) { document . write ( i + " " ) ; } } } } let L = 5 , R = 100 ; find ( L , R ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function digit_sum ( n ) { let sum = 0 , m ; while ( n > 0 ) { m = n % 10 ; sum = sum + m ; n = parseInt ( n / 10 , 10 ) ; } return ( sum ) ; } function reverse ( n ) { let r = 0 ; while ( n != 0 ) { r = r * 10 ; r = r + n % 10 ; n = parseInt ( n / 10 , 10 ) ; } return ( r ) ; } function operation ( n ) { let i = 1 , a , count = 0 , r ; while ( count < n ) { a = digit_sum ( i ) ; r = reverse ( i ) ; if ( i % a == 0 && r % a == 0 ) { document . write ( i + " " ) ; count ++ ; i ++ ; } else i ++ ; } } let n = 10 ; operation ( n ) ;

Accumulator variables: count, i
Javascript program:
function createSets ( N ) { if ( N <= 2 ) { document . write ( " " ) ; return ; } for ( let i = 2 ; i <= N ; i += 2 ) document . write ( i + " " ) ; document . write ( " " ) ; for ( let i = 1 ; i <= N ; i += 2 ) { document . write ( i + " " ) ; } } let N = 6 ; createSets ( N ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
var ans = 0 ; var graph = Array . from ( Array ( 100 ) , ( ) => Array ( ) ) ; var weight = Array . from ( Array ( 100 ) , ( ) => Array ( ) ) ; function isPowerful ( n ) { while ( n % 2 == 0 ) { var power = 0 ; while ( n % 2 == 0 ) { n /= 2 ; power ++ ; } if ( power == 1 ) return false ; } for ( var factor = 3 ; factor <= Math . sqrt ( n ) ; factor += 2 ) { var power = 0 ; while ( n % factor == 0 ) { n = n / factor ; power ++ ; } if ( power == 1 ) return false ; } return ( n == 1 ) ; } function dfs ( node , parent ) { if ( isPowerful ( weight [ node ] ) ) ans += 1 ; graph [ node ] . forEach ( to => { if ( to != parent ) dfs ( to , node ) ; } ) ; } weight [ 1 ] = 5 ; weight [ 2 ] = 10 ; weight [ 3 ] = 11 ; weight [ 4 ] = 8 ; weight [ 5 ] = 6 ; graph [ 1 ] . push ( 2 ) ; graph [ 2 ] . push ( 3 ) ; graph [ 2 ] . push ( 4 ) ; graph [ 1 ] . push ( 5 ) ; dfs ( 1 , 1 ) ; document . write ( ans ) ;

Index/key variables: node
Accumulator variables: ans, factor, n, power
Iterator variables: factor
Javascript program:
function CountWays ( N , M ) { var count = 1 ; count = Math . pow ( 3 , M + N ) ; count *= Math . pow ( 2 , M * N ) ; return count ; } var N = 3 ; var M = 2 ; document . write ( CountWays ( N , M ) ) ;

Accumulator variables: count
Javascript program:
function findNthNumber ( N ) { let arr = new Array ( N + 1 ) ; let q = [ ] ; for ( let i = 1 ; i <= 9 ; i ++ ) q . push ( i ) ; for ( let i = 1 ; i <= N ; i ++ ) { arr [ i ] = q [ 0 ] ; q . shift ( ) ; if ( arr [ i ] % 10 != 0 ) q . push ( arr [ i ] * 10 + arr [ i ] % 10 - 1 ) ; q . push ( arr [ i ] * 10 + arr [ i ] % 10 ) ; if ( arr [ i ] % 10 != 9 ) q . push ( arr [ i ] * 10 + arr [ i ] % 10 + 1 ) ; } document . write ( arr [ N ] + " " ) ; } let N = 21 ; findNthNumber ( N ) ;

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findUniqueElements ( arr , N , K ) { var s = new Set ( arr ) ; var arr_sum = arr . reduce ( ( a , b ) => a + b , 0 ) ; var set_sum = 0 ; s . forEach ( function ( value ) { set_sum += value ; } ) document . write ( Math . floor ( ( K * set_sum - arr_sum ) / ( K - 1 ) ) ) ; } var arr = [ 12 , 1 , 12 , 3 , 12 , 1 , 1 , 2 , 3 , 2 , 2 , 3 , 7 ] ; var N = arr . length ; var K = 3 ; findUniqueElements ( arr , N , K ) ;

Accumulator variables: set_sum
Javascript program:
function dydx ( x , y ) { return ( x - y ) / 2 ; } function Gill ( x0 , y0 , x , h ) { let n = ( ( x - x0 ) / h ) ; let k1 , k2 , k3 , k4 ; let y = y0 ; for ( let i = 1 ; i <= n ; i ++ ) { k1 = h * dydx ( x0 , y ) ; k2 = h * dydx ( x0 + 0.5 * h , y + 0.5 * k1 ) ; k3 = h * dydx ( x0 + 0.5 * h , y + 0.5 * ( - 1 + Math . sqrt ( 2 ) ) * k1 + k2 * ( 1 - 0.5 * Math . sqrt ( 2 ) ) ) ; k4 = h * dydx ( x0 + h , y - ( 0.5 * Math . sqrt ( 2 ) ) * k2 + k3 * ( 1 + 0.5 * Math . sqrt ( 2 ) ) ) ; y = y + ( 1.0 / 6 ) * ( k1 + ( 2 - Math . sqrt ( 2 ) ) * k2 + ( 2 + Math . sqrt ( 2 ) ) * k3 + k4 ) ; x0 = x0 + h ; } return y ; } let x0 = 0 , y = 3.0 , x = 5.0 , h = 0.2 ; document . write ( " " , Gill ( x0 , y , x , h ) . toFixed ( 6 ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function PrintReverseOrder ( N ) { for ( let i = N ; i > 0 ; i -- ) document . write ( i + " " ) ; } let N = 5 ; PrintReverseOrder ( N ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function ArithmeticMean ( A , B ) { return ( ( A + B ) / 2 ) ; } function HarmonicMean ( A , B ) { return ( 2 * A * B ) / ( A + B ) ; } function CheckArithmeticHarmonic ( arr , A , B , N ) { let AM = ArithmeticMean ( A , B ) ; let HM = HarmonicMean ( A , B ) ; let Hash = new Map ( ) ; for ( let i = 0 ; i < N ; i ++ ) { Hash . set ( arr [ i ] , 1 ) ; } if ( Hash . get ( A ) != 0 && Hash . get ( B ) != 0 ) { if ( Hash . get ( AM ) != 0 && Hash . get ( HM ) != 0 ) { document . write ( " " ) ; document . write ( Math . sqrt ( AM * HM ) . toFixed ( 2 ) ) ; } else { document . write ( " " ) ; } } else { document . write ( " " ) ; } } let arr = [ 1.0 , 2.0 , 2.5 , 3.0 , 4.0 , 4.5 , 5.0 , 6.0 ] ; let N = ( arr . length ) ; let A = 3.0 ; let B = 6.0 ; CheckArithmeticHarmonic ( arr , A , B , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function PythagoreanTriplet ( n ) { let flag = 0 ; for ( let a = 1 ; a < n ; a ++ ) { let b = ( n * n - 2 * n * a ) / ( 2 * n - 2 * a ) ; let c = n - a - b ; if ( a * a + b * b == c * c && b > 0 && c > 0 ) { document . write ( a + " " + b + " " + c ) ; flag = 1 ; break ; } } if ( flag == 0 ) { document . write ( " " ) ; } return ; } let N = 12 ; PythagoreanTriplet ( N ) ;

Accumulator variables: a
Iterator variables: a
Javascript program:
function check ( X , K ) { var prime , temp , sqr , i ; prime = 0 ; temp = X ; sqr = parseInt ( Math . sqrt ( X ) ) ; for ( i = 2 ; i <= sqr ; i ++ ) { while ( temp % i == 0 ) { temp = parseInt ( temp / i ) ; prime ++ ; } } if ( temp > 2 ) prime ++ ; if ( X == 1 ) return false ; if ( prime == 1 && K == 1 ) return true ; else if ( prime >= K ) return true ; else return false ; } var X , K ; X = 4 ; K = 2 ; if ( check ( X , K ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i, prime
Iterator variables: i
Javascript program:
class Node { constructor ( key ) { this . left = null ; this . right = null ; this . key = key ; } } function newNode ( key ) { let temp = new Node ( key ) ; return ( temp ) ; } let N = 1000000 ; let prime = [ ] ; function SieveOfEratosthenes ( ) { let check = new Array ( N + 1 ) ; check . fill ( true ) ; for ( let p = 2 ; p * p <= N ; p ++ ) { if ( check [ p ] == true ) { prime . push ( p ) ; for ( let i = p * p ; i <= N ; i += p ) check [ i ] = false ; } } } function isPathCo_Prime ( path ) { let max = 0 ; for ( let x = 0 ; x < path . length ; x ++ ) { if ( max < path [ x ] ) max = path [ x ] ; } for ( let i = 0 ; i * prime [ i ] <= parseInt ( max / 2 , 10 ) ; i ++ ) { let ct = 0 ; for ( let x = 0 ; x < path . length ; x ++ ) { if ( path [ x ] % prime [ i ] == 0 ) ct ++ ; } if ( ct > 1 ) { return false ; } } return true ; } function printCoPrimePaths ( path ) { for ( let x = 0 ; x < path . length ; x ++ ) { document . write ( path [ x ] + " " ) ; } document . write ( " " ) ; } function findCo_PrimePaths ( root , path ) { if ( root == null ) return ; path . push ( root . key ) ; findCo_PrimePaths ( root . left , path ) ; findCo_PrimePaths ( root . right , path ) ; if ( root . left == null && root . right == null ) { if ( isPathCo_Prime ( path ) ) { printCoPrimePaths ( path ) ; } } path . pop ( ) ; } function printCo_PrimePaths ( node ) { SieveOfEratosthenes ( ) ; let path = [ ] ; findCo_PrimePaths ( node , path ) ; } let root = newNode ( 10 ) ; root . left = newNode ( 48 ) ; root . right = newNode ( 3 ) ; root . right . left = newNode ( 11 ) ; root . right . right = newNode ( 37 ) ; root . right . left . left = newNode ( 7 ) ; root . right . left . right = newNode ( 29 ) ; root . right . right . left = newNode ( 42 ) ; root . right . right . right = newNode ( 19 ) ; root . right . right . right . left = newNode ( 7 ) ; printCo_PrimePaths ( root ) ;

Index/key variables: i, p, x
Accumulator variables: ct, i, p, x
Iterator variables: i, p, x
Class/struct names: Node
Javascript program:
let mod = 1000000007 ; function countSubsets ( a , n ) { let answer = 0 ; for ( let i = 0 ; i < ( 1 << n ) ; i ++ ) { let bitwiseAND = - 1 ; let bitwiseOR = 0 ; let bitwiseXOR = 0 ; for ( let j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) != 0 ) { if ( bitwiseAND == - 1 ) bitwiseAND = a [ j ] ; else bitwiseAND &= a [ j ] ; bitwiseOR |= a [ j ] ; bitwiseXOR ^= a [ j ] ; } } if ( bitwiseAND == bitwiseOR && bitwiseOR == bitwiseXOR ) answer = ( answer + 1 ) % mod ; } return answer ; } let N = 6 ; let A = [ 1 , 3 , 2 , 1 , 2 , 1 ] ; document . write ( countSubsets ( A , N ) ) ;

Index/key variables: j
Accumulator variables: bitwiseAND, bitwiseOR, bitwiseXOR, i, j
Iterator variables: i, j
Javascript program:
function count ( arr , N , K ) { let count = 0 , ans = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == K ) { count = count + 1 ; } else { ans += ( count * ( count + 1 ) ) / 2 ; count = 0 ; } } ans = ans + ( count * ( count + 1 ) ) / 2 ; return ans ; } let arr = [ 1 , 0 , 0 , 1 , 1 , 0 , 0 ] ; let N = arr . length ; let K = 0 ; document . write ( count ( arr , N , K ) ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function convertToTernary ( N ) { if ( N == 0 ) return ; let x = N % 3 ; N = parseInt ( N / 3 , 10 ) ; if ( x < 0 ) N += 1 ; convertToTernary ( N ) ; if ( x < 0 ) document . write ( x + ( 3 * - 1 ) ) ; else document . write ( x ) ; } function convert ( Decimal ) { document . write ( " " + Decimal + " " ) ; if ( Decimal != 0 ) { convertToTernary ( Decimal ) ; } else document . write ( " " + " " ) ; } let Decimal = 2747 ; convert ( Decimal ) ;

Accumulator variables: N