dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function find_Square_369 ( num ) { let a , b , c , d ; if ( num [ 0 ] == ' ' ) { a = ' ' ; b = ' ' ; c = ' ' ; d = ' ' ; } else if ( num [ 0 ] == ' ' ) { a = ' ' ; b = ' ' ; c = ' ' ; d = ' ' ; } else { a = ' ' ; b = ' ' ; c = ' ' ; d = ' ' ; } let result = " " ; let size = num . length ; for ( let i = 1 ; i < size ; i ++ ) result += a ; result += b ; for ( let i = 1 ; i < size ; i ++ ) result += c ; result += d ; return result ; } let num_3 , num_6 , num_9 ; num_3 = " " ; num_6 = " " ; num_9 = " " ; let result = " " ; result = find_Square_369 ( num_3 ) ; document . write ( " " + num_3 + " " + result + " " ) ; result = find_Square_369 ( num_6 ) ; document . write ( " " + num_9 + " " + result + " " ) ; result = find_Square_369 ( num_9 ) ; document . write ( " " + num_9 + " " + result + " " ) ;

Accumulator variables: i, result
Iterator variables: i
Javascript program:
var ans = 1 ; var mod = 1000000007 * 120 ; for ( var i = 0 ; i < 5 ; i ++ ) ans = ( ans * ( 55555 - i ) ) % mod ; ans = ans / 120 ; document . write ( " " + " " + ans ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function fact ( n ) { if ( n == 0 n == 1 ) return 1 ; let ans = 1 ; for ( let i = 1 ; i <= n ; i ++ ) ans = ans * i ; return ans ; } function nCr ( n , r ) { let Nr = n , Dr = 1 , ans = 1 ; for ( let i = 1 ; i <= r ; i ++ ) { ans = parseInt ( ( ans * Nr ) / ( Dr ) , 10 ) ; Nr -- ; Dr ++ ; } return ans ; } function solve ( n ) { let N = 2 * n - 2 ; let R = n - 1 ; return nCr ( N , R ) * fact ( n - 1 ) ; } let n = 6 ; document . write ( solve ( n ) ) ;

Accumulator variables: Dr, Nr, i
Iterator variables: i
Javascript program:
function pythagoreanTriplet ( n ) { for ( let i = 1 ; i <= n / 3 ; i ++ ) { for ( let j = i + 1 ; j <= n / 2 ; j ++ ) { let k = n - i - j ; if ( i * i + j * j == k * k ) { document . write ( i + " " + j + " " + k ) ; return ; } } } document . write ( " " ) ; } let n = 12 ; pythagoreanTriplet ( n ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function factorial ( n ) { let f = 1 ; for ( let i = 2 ; i <= n ; i ++ ) f *= i ; return f ; } function series ( A , X , n ) { let nFact = factorial ( n ) ; for ( let i = 0 ; i < n + 1 ; i ++ ) { let niFact = factorial ( n - i ) ; let iFact = factorial ( i ) ; let aPow = Math . pow ( A , n - i ) ; let xPow = Math . pow ( X , i ) ; document . write ( ( nFact * aPow * xPow ) / ( niFact * iFact ) + " " ) ; } } let A = 3 , X = 4 , n = 5 ; series ( A , X , n ) ;

Accumulator variables: f, i
Iterator variables: i
Javascript program:
function seiresSum ( n , a ) { let res = 0 , i ; for ( i = 0 ; i < 2 * n ; i ++ ) { if ( i % 2 == 0 ) res += a [ i ] * a [ i ] ; else res -= a [ i ] * a [ i ] ; } return res ; } let n = 2 ; let a = [ 1 , 2 , 3 , 4 ] ; document . write ( seiresSum ( n , a ) ) ;

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Javascript program:
function power ( n , r ) { let count = 0 ; for ( let i = r ; ( n / i ) >= 1 ; i = i * r ) count += n / i ; return count ; } let n = 6 , r = 3 ; document . write ( power ( n , r ) ) ;

Accumulator variables: count
Iterator variables: i
Javascript program:
function avg_of_odd_num ( n ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) sum += ( 2 * i + 1 ) ; return sum / n ; } let n = 20 ; document . write ( avg_of_odd_num ( n ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function fib ( f , N ) { f [ 1 ] = 1 ; f [ 2 ] = 1 ; for ( var i = 3 ; i <= N ; i ++ ) f [ i ] = f [ i - 1 ] + f [ i - 2 ] ; } function fiboTriangle ( n ) { var N = ( n * ( n + 1 ) ) / 2 ; var f = [ ... Array ( N + 1 ) ] ; fib ( f , N ) ; var fiboNum = 1 ; for ( var i = 1 ; i <= n ; i ++ ) { for ( var j = 1 ; j <= i ; j ++ ) document . write ( f [ fiboNum ++ ] + " " ) ; document . write ( " " ) ; } } var n = 5 ; fiboTriangle ( n ) ;

Index/key variables: i
Accumulator variables: fiboNum, i, j
Iterator variables: i, j
Javascript program:
function averageOdd ( n ) { if ( n % 2 == 0 ) { document . write ( " " ) ; return - 1 ; } let sum = 0 , count = 0 ; while ( n >= 1 ) { count ++ ; sum += n ; n = n - 2 ; } return sum / count ; } let n = 15 ; document . write ( averageOdd ( n ) ) ;

Accumulator variables: count, sum
Javascript program:
class Rational { constructor ( nume , deno ) { this . nume = nume ; this . deno = deno ; } } function lcm ( a , b ) { return ( a * b ) / ( __gcd ( a , b ) ) ; } function maxRational ( first , sec ) { let k = lcm ( first . deno , sec . deno ) ; let nume1 = first . nume ; let nume2 = sec . nume ; nume1 *= k / ( first . deno ) ; nume2 *= k / ( sec . deno ) ; return ( nume2 < nume1 ) ? first : sec ; } function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } let first = new Rational ( 3 , 2 ) ; let sec = new Rational ( 3 , 4 ) ; let res = maxRational ( first , sec ) ; document . write ( res . nume + " " + res . deno ) ;

Accumulator variables: nume1, nume2
Class/struct names: Rational
Javascript program:
function TrinomialValue ( n , k ) { if ( n == 0 && k == 0 ) return 1 ; if ( k < - n k > n ) return 0 ; return TrinomialValue ( n - 1 , k - 1 ) + TrinomialValue ( n - 1 , k ) + TrinomialValue ( n - 1 , k + 1 ) ; } function printTrinomial ( n ) { for ( let i = 0 ; i < n ; i ++ ) { for ( let j = - i ; j <= 0 ; j ++ ) document . write ( TrinomialValue ( i , j ) + " " ) ; for ( let j = 1 ; j <= i ; j ++ ) document . write ( TrinomialValue ( i , j ) + " " ) ; document . write ( " " ) ; } } let n = 4 ; printTrinomial ( n ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
var MAX = 10 function TrinomialValue ( dp , n , k ) { if ( k < 0 ) k = - k ; if ( dp [ n ] [ k ] != 0 ) return dp [ n ] [ k ] ; if ( n == 0 && k == 0 ) return 1 ; if ( k < - n k > n ) return 0 ; return ( dp [ n ] [ k ] = TrinomialValue ( dp , n - 1 , k - 1 ) + TrinomialValue ( dp , n - 1 , k ) + TrinomialValue ( dp , n - 1 , k + 1 ) ) ; } function printTrinomial ( n ) { var dp = Array . from ( Array ( MAX ) , ( ) => Array ( MAX ) . fill ( 0 ) ) ; for ( var i = 0 ; i < n ; i ++ ) { for ( var j = - i ; j <= 0 ; j ++ ) document . write ( TrinomialValue ( dp , i , j ) + " " ) ; for ( var j = 1 ; j <= i ; j ++ ) document . write ( TrinomialValue ( dp , i , j ) + " " ) ; document . write ( " " ) ; } } var n = 4 ; printTrinomial ( n ) ;

Index/key variables: k, n
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function sumOfLargePrimeFactor ( n ) { let prime = new Array ( n + 1 ) ; let sum = 0 ; let max = n / 2 ; for ( let i = 0 ; i < n + 1 ; i ++ ) prime [ i ] = 0 ; for ( let p = 2 ; p <= max ; p ++ ) { if ( prime [ p ] == 0 ) { for ( let i = p * 2 ; i <= n ; i += p ) prime [ i ] = p ; } } for ( let p = 2 ; p <= n ; p ++ ) { if ( prime [ p ] ) sum += prime [ p ] ; else sum += p ; } return sum ; } let n = 12 ; document . write ( " " + sumOfLargePrimeFactor ( n ) ) ;

Index/key variables: i, p
Accumulator variables: i, p, sum
Iterator variables: i, p
Javascript program:
function counDivisors ( X ) { let count = 0 ; for ( let i = 1 ; i <= X ; ++ i ) { if ( X % i == 0 ) { count ++ ; } } return count ; } function countDivisorsMult ( arr , n ) { let mul = 1 ; for ( let i = 0 ; i < n ; ++ i ) mul *= arr [ i ] ; return counDivisors ( mul ) ; } let arr = [ 2 , 4 , 6 ] ; let n = arr . length ; document . write ( countDivisorsMult ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: count, mul
Iterator variables: i
Javascript program:
function SieveOfEratosthenes ( largest , prime ) { var isPrime = Array ( largest + 1 ) . fill ( true ) ; var p , i ; for ( p = 2 ; p * p <= largest ; p ++ ) { if ( isPrime [ p ] == true ) { for ( i = p * 2 ; i <= largest ; i += p ) isPrime [ i ] = false ; } } for ( p = 2 ; p <= largest ; p ++ ) if ( isPrime [ p ] ) prime . push ( p ) ; } function countDivisorsMult ( arr , n ) { var largest = Math . max . apply ( null , arr ) ; var prime = [ ] ; SieveOfEratosthenes ( largest , prime ) ; var j ; var mp = new Map ( ) ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < prime . length ; j ++ ) { while ( arr [ i ] > 1 && arr [ i ] % prime [ j ] == 0 ) { arr [ i ] /= prime [ j ] ; if ( mp . has ( prime [ j ] ) ) mp . set ( prime [ j ] , mp . get ( prime [ j ] ) + 1 ) ; else mp . set ( prime [ j ] , 1 ) ; } } if ( arr [ i ] != 1 ) { if ( mp . has ( arr [ i ] ) ) mp . set ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; else mp . set ( arr [ i ] , 1 ) ; } } var res = 1 ; for ( const [ key , value ] of mp . entries ( ) ) { res *= ( value + 1 ) ; } return res ; } var arr = [ 2 , 4 , 6 ] ; var n = arr . length ; document . write ( countDivisorsMult ( arr , n ) ) ;

Index/key variables: i, j, p
Accumulator variables: i, j, p, res
Iterator variables: i, j, p
Javascript program:
function findPrimeNos ( L , R , M ) { for ( var i = L ; i <= R ; i ++ ) { if ( M . has ( i ) ) M . set ( i , M . get ( i ) + 1 ) else M . set ( i , 1 ) } if ( M . has ( 1 ) ) { M . delete ( 1 ) ; } for ( var i = 2 ; i <= parseInt ( Math . sqrt ( R ) ) ; i ++ ) { var multiple = 2 ; while ( ( i * multiple ) <= R ) { if ( M . has ( i * multiple ) ) { M . delete ( i * multiple ) ; } multiple ++ ; } } return M ; } function getPrimePairs ( L , R , K ) { var M = new Map ( ) ; M = findPrimeNos ( L , R , M ) ; M . forEach ( ( value , key ) => { if ( M . has ( key + K ) ) { document . write ( " " + key + " " + ( key + K ) + " " ) ; } } ) ; } var L = 1 , R = 19 ; var K = 6 ; getPrimePairs ( L , R , K ) ;

Accumulator variables: i, multiple
Iterator variables: i
Javascript program:
function freqPairs ( arr , n ) { let max = Math . max ( ... arr ) ; let freq = new Array ( max + 1 ) . fill ( 0 ) ; let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) freq [ arr [ i ] ] ++ ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 2 * arr [ i ] ; j <= max ; j += arr [ i ] ) { if ( freq [ j ] >= 1 ) count += freq [ j ] ; } if ( freq [ arr [ i ] ] > 1 ) { count += freq [ arr [ i ] ] - 1 ; freq [ arr [ i ] ] -- ; } } return count ; } let arr = [ 3 , 2 , 4 , 2 , 6 ] ; let n = arr . length ; document . write ( freqPairs ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function prletNthElement ( n ) { let arr = Array ( n + 1 ) . fill ( 0 ) ; arr [ 1 ] = 3 ; arr [ 2 ] = 5 ; for ( i = 3 ; i <= n ; i ++ ) { if ( i % 2 != 0 ) arr [ i ] = arr [ i / 2 ] * 10 + 3 ; else arr [ i ] = arr [ ( i / 2 ) - 1 ] * 10 + 5 ; } return arr [ n ] ; } let n = 6 ; document . write ( prletNthElement ( n ) ) ;

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Javascript program:
function series ( A , X , n ) { let term = Math . pow ( A , n ) ; document . write ( term + " " ) ; for ( let i = 1 ; i <= n ; i ++ ) { term = term * X * ( n - i + 1 ) / ( i * A ) ; document . write ( term + " " ) ; } } let A = 3 , X = 4 , n = 5 ; series ( A , X , n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function averageEven ( n ) { if ( n % 2 != 0 ) { document . write ( " " ) ; return - 1 ; } let sum = 0 , count = 0 ; while ( n >= 2 ) { count ++ ; sum += n ; n = n - 2 ; } return sum / count ; } let n = 16 ; document . write ( averageEven ( n ) ) ;

Accumulator variables: count, sum
Javascript program:
function counLastDigitK ( low , high , k ) { let count = 0 ; for ( let i = low ; i <= high ; i ++ ) if ( i % 10 == k ) count ++ ; return count ; } let low = 3 ; let high = 35 ; let k = 3 ; document . write ( counLastDigitK ( low , high , k ) ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function printTaxicab2 ( N ) { let i = 1 ; count = 0 ; while ( count < N ) { let int_count = 0 ; for ( let j = 1 ; j <= Math . pow ( i , 1.0 / 3 ) ; j ++ ) for ( let k = j + 1 ; k <= Math . pow ( i , 1.0 / 3 ) ; k ++ ) if ( j * j * j + k * k * k == i ) int_count ++ ; if ( int_count == 2 ) { count ++ ; document . write ( count + " " + i + " " ) ; } i ++ ; } } let N = 5 ; printTaxicab2 ( N ) ;

Accumulator variables: count, i, int_count, j, k
Iterator variables: j, k
Javascript program:
function isComposite ( n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return false ; if ( n % 2 == 0 n % 3 == 0 ) return true ; for ( let i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } isComposite ( 11 ) ? document . write ( " " + " " ) : document . write ( " " + " " ) ; isComposite ( 15 ) ? document . write ( " " + " " ) : document . write ( " " + " " ) ;

Iterator variables: i
Javascript program:
function isPrime ( n ) { if ( n <= 1 ) return false ; for ( let i = 2 ; i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } function findPrime ( n ) { let num = n + 1 ; while ( num > 0 ) { if ( isPrime ( num ) ) return num ; num = num + 1 ; } return 0 ; } function minNumber ( arr , n ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; if ( isPrime ( sum ) ) return 0 ; let num = findPrime ( sum ) ; return num - sum ; } let arr = [ 2 , 4 , 6 , 8 , 12 ] ; let n = arr . length ; document . write ( minNumber ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function fact ( n ) { if ( n == 0 ) return 1 ; return n * fact ( n - 1 ) ; } function div ( x ) { let ans = 0 ; for ( let i = 1 ; i <= x ; i ++ ) if ( x % i == 0 ) ans += i ; return ans ; } function sumFactDiv ( n ) { return div ( fact ( n ) ) ; } let n = 4 ; document . write ( sumFactDiv ( n ) ) ;

Accumulator variables: ans, i
Iterator variables: i
Javascript program:
let allPrimes = [ ] ; function sieve ( n ) { let prime = new Array ( n + 1 ) ; for ( let i = 0 ; i < n + 1 ; i ++ ) prime [ i ] = true ; for ( let p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( let i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } for ( let p = 2 ; p <= n ; p ++ ) if ( prime [ p ] ) allPrimes . push ( p ) ; } function factorialDivisors ( n ) { sieve ( n ) ; let result = 1 ; for ( let i = 0 ; i < allPrimes . length ; i ++ ) { let p = allPrimes [ i ] ; let exp = 0 ; while ( p <= n ) { exp = exp + Math . floor ( n / p ) ; p = p * allPrimes [ i ] ; } result = Math . floor ( result * ( Math . pow ( allPrimes [ i ] , exp + 1 ) - 1 ) / ( allPrimes [ i ] - 1 ) ) ; } return result ; } document . write ( factorialDivisors ( 4 ) ) ;

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Javascript program:
function checkPandigital ( b , n ) { if ( n . length < b ) return 0 ; let hash = [ ] ; for ( let i = 0 ; i < b ; i ++ ) hash [ i ] = 0 ; for ( let i = 0 ; i < n . length ; i ++ ) { if ( n [ i ] >= ' ' && n [ i ] <= ' ' ) hash [ n [ i ] - ' ' ] = 1 ; else if ( n . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) <= b - 11 ) hash [ n . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) + 10 ] = 1 ; } for ( let i = 0 ; i < b ; i ++ ) if ( hash [ i ] == 0 ) return 0 ; return 1 ; } let b = 13 ; let n = " " ; if ( checkPandigital ( b , n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var MAX = 10000 ; var prodDig = Array . from ( { length : MAX } , ( _ , i ) => 0 ) ; function getDigitProduct ( x ) { if ( x < 10 ) return x ; if ( prodDig [ x ] != 0 ) return prodDig [ x ] ; var prod = ( x % 10 ) * getDigitProduct ( parseInt ( x / 10 ) ) ; return ( prodDig [ x ] = prod ) ; } function findSeed ( n ) { var res = [ ] ; for ( var i = 1 ; i <= parseInt ( n / 2 ) ; i ++ ) if ( i * getDigitProduct ( i ) == n ) res . push ( i ) ; if ( res . length == 0 ) { document . write ( " " ) ; return ; } for ( i = 0 ; i < res . length ; i ++ ) document . write ( res [ i ] + " " ) ; } var n = 138 ; findSeed ( n ) ;

Index/key variables: i, x
Accumulator variables: i
Iterator variables: i
Javascript program:
function maxPrimefactorNum ( N ) { var arr = Array . from ( { length : N + 5 } , ( _ , i ) => 0 ) ; for ( i = 2 ; i * i <= N ; i ++ ) { if ( arr [ i ] == 0 ) { for ( j = 2 * i ; j <= N ; j += i ) { arr [ j ] ++ ; } } arr [ i ] = 1 ; } var maxval = 0 , maxvar = 1 ; for ( i = 1 ; i <= N ; i ++ ) { if ( arr [ i ] > maxval ) { maxval = arr [ i ] ; maxvar = i ; } } return maxvar ; } var N = 40 ; document . write ( maxPrimefactorNum ( N ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function SubArraySum ( arr , n ) { let result = 0 ; for ( let i = 0 ; i < n ; i ++ ) result += ( arr [ i ] * ( i + 1 ) * ( n - i ) ) ; return result ; } let arr = [ 1 , 2 , 3 ] ; let n = arr . length ; document . write ( " " + SubArraySum ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Javascript program:
function highestPowerof2 ( n ) { let res = 0 ; for ( let i = n ; i >= 1 ; i -- ) { if ( ( i & ( i - 1 ) ) == 0 ) { res = i ; break ; } } return res ; } let n = 10 ; document . write ( highestPowerof2 ( n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function findPairs ( n ) { var cubeRoot = parseInt ( Math . pow ( n , 1.0 / 3.0 ) ) ; var cube = Array . from ( { length : cubeRoot + 1 } , ( _ , i ) => 0 ) ; for ( i = 1 ; i <= cubeRoot ; i ++ ) cube [ i ] = i * i * i ; var l = 1 ; var r = cubeRoot ; while ( l < r ) { if ( cube [ l ] + cube [ r ] < n ) l ++ ; else if ( cube [ l ] + cube [ r ] > n ) r -- ; else { document . write ( " " + l + " " + r + " " ) ; l ++ ; r -- ; } } } var n = 20683 ; findPairs ( n ) ;

Index/key variables: i, l, r
Accumulator variables: i, l, r
Iterator variables: i
Javascript program:
function printDivisors ( n ) { let v = [ ] ; let t = 0 ; for ( let i = 1 ; i <= parseInt ( Math . sqrt ( n ) ) ; i ++ ) { if ( n % i == 0 ) { if ( parseInt ( n / i ) == i ) document . write ( i + " " ) ; else { document . write ( i + " " ) ; v [ t ++ ] = parseInt ( n / i ) ; } } } for ( let i = v . length - 1 ; i >= 0 ; i -- ) { document . write ( v [ i ] + " " ) ; } } document . write ( " " ) ; printDivisors ( 100 ) ;

Index/key variables: i
Accumulator variables: i, t
Iterator variables: i
Javascript program:
function printDivisors ( n ) { for ( var i = 1 ; i * i < n ; i ++ ) { if ( n % i == 0 ) document . write ( i + " " ) ; } for ( var i = Math . sqrt ( n ) ; i >= 1 ; i -- ) { if ( n % i == 0 ) document . write ( " " + n / i ) ; } } document . write ( " " ) ; printDivisors ( 100 ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function printDivisors ( n ) { for ( i = 1 ; i <= n ; i ++ ) if ( n % i == 0 ) document . write ( i + " " ) ; } document . write ( " " + " " ) ; printDivisors ( 100 ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function printDivisors ( n ) { for ( let i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( parseInt ( n / i , 10 ) == i ) document . write ( i ) ; else document . write ( i + " " + parseInt ( n / i , 10 ) + " " ) ; } } } document . write ( " " ) ; printDivisors ( 100 ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function SieveOfAtkin ( limit ) { if ( limit > 2 ) document . write ( 2 + " " ) ; if ( limit > 3 ) document . write ( 3 + " " ) ; let sieve = new Array ( ) sieve [ limit ] = 0 ; for ( let i = 0 ; i < limit ; i ++ ) sieve [ i ] = false ; for ( let x = 1 ; x * x < limit ; x ++ ) { for ( let y = 1 ; y * y < limit ; y ++ ) { let n = ( 4 * x * x ) + ( y * y ) ; if ( n <= limit && ( n % 12 == 1 n % 12 == 5 ) ) sieve [ n ] ^= true ; n = ( 3 * x * x ) + ( y * y ) ; if ( n <= limit && n % 12 == 7 ) sieve [ n ] = true ; n = ( 3 * x * x ) - ( y * y ) ; if ( x > y && n <= limit && n % 12 == 11 ) sieve [ n ] ^= true ; } } for ( let r = 5 ; r * r < limit ; r ++ ) { if ( sieve [ r ] ) { for ( i = r * r ; i < limit ; i += r * r ) sieve [ i ] = false ; } } for ( let a = 5 ; a < limit ; a ++ ) if ( sieve [ a ] ) document . write ( a , " " ) ; } let limit = 20 ; SieveOfAtkin ( limit ) ;

Index/key variables: a, i, limit, n, r
Accumulator variables: a, i, r, x, y
Iterator variables: a, i, r, x, y
Javascript program:
function eval ( a , op , b ) { if ( op == ' ' ) { return a + b ; } if ( op == ' ' ) { return a - b ; } if ( op == ' ' ) { return a * b ; } return Number . MAX_VALUE ; } function evaluateAll ( expr , low , high ) { let res = [ ] ; if ( low == high ) { res . push ( expr [ low ] - ' ' ) ; return res ; } if ( low == ( high - 2 ) ) { let num = eval ( expr [ low ] - ' ' , expr [ low + 1 ] , expr [ low + 2 ] - ' ' ) ; res . push ( num ) ; return res ; } for ( let i = low + 1 ; i <= high ; i += 2 ) { let l = evaluateAll ( expr , low , i - 1 ) ; let r = evaluateAll ( expr , i + 1 , high ) ; for ( let s1 = 0 ; s1 < l . length ; s1 ++ ) { for ( let s2 = 0 ; s2 < r . length ; s2 ++ ) { let val = eval ( l [ s1 ] , expr [ i ] , r [ s2 ] ) ; res . push ( val ) ; } } } return res ; } let expr = " " ; let len = expr . length ; let ans = evaluateAll ( expr , 0 , len - 1 ) ; for ( let i = 0 ; i < ans . length ; i ++ ) { document . write ( ans [ i ] + " " ) ; }

Index/key variables: i, low, s1, s2
Accumulator variables: i, s1, s2
Iterator variables: i, s1, s2
Javascript program:
function isLucky ( n ) { var arr = Array ( 10 ) . fill ( 0 ) ; for ( var i = 0 ; i < 10 ; i ++ ) arr [ i ] = false ; while ( n > 0 ) { var digit = n % 10 ; if ( arr [ digit ] ) return false ; arr [ digit ] = true ; n = parseInt ( n / 10 ) ; } return true ; } var arr = [ 1291 , 897 , 4566 , 1232 , 80 , 700 ] var n = arr . length ; for ( var i = 0 ; i < n ; i ++ ) isLucky ( arr [ i ] ) ? document . write ( arr [ i ] + " " ) : document . write ( arr [ i ] + " " ) ;

Index/key variables: digit, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function printSquares ( n ) { let square = 0 , odd = 1 ; for ( let x = 0 ; x < n ; x ++ ) { document . write ( square + " " ) ; square = square + odd ; odd = odd + 2 ; } } let n = 5 ; printSquares ( n ) ;

Accumulator variables: x
Iterator variables: x
Javascript program:
var rev_num = 0 ; var base_pos = 1 ; function reversDigits ( num ) { if ( num > 0 ) { reversDigits ( Math . floor ( num / 10 ) ) ; rev_num += ( num % 10 ) * base_pos ; base_pos *= 10 ; } return rev_num ; } let num = 4562 ; document . write ( " " + reversDigits ( num ) ) ;

Accumulator variables: base_pos, rev_num
Javascript program:
function RecursiveFunction ( ref , bit ) { if ( ref . length == 0 bit < 0 ) return 0 ; let curr_on = [ ] , curr_off = [ ] ; for ( let i = 0 ; i < ref . length ; i ++ ) { if ( ( ( ref [ i ] >> bit ) & 1 ) == 0 ) curr_off . push ( ref [ i ] ) ; else curr_on . push ( ref [ i ] ) ; } if ( curr_off . length == 0 ) return RecursiveFunction ( curr_on , bit - 1 ) ; if ( curr_on . length == 0 ) return RecursiveFunction ( curr_off , bit - 1 ) ; return Math . min ( RecursiveFunction ( curr_off , bit - 1 ) , RecursiveFunction ( curr_on , bit - 1 ) ) + ( 1 << bit ) ; } function PrintMinimum ( a , n ) { let v = [ ] ; for ( let i = 0 ; i < n ; i ++ ) v . push ( a [ i ] ) ; document . write ( RecursiveFunction ( v , 30 ) + " " ) ; } let arr = [ 3 , 2 , 1 ] ; let size = arr . length ; PrintMinimum ( arr , size ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function cntElements ( arr , n ) { let cnt = 0 ; for ( let i = 0 ; i < n - 2 ; i ++ ) { if ( arr [ i ] == ( arr [ i + 1 ] ^ arr [ i + 2 ] ) ) { cnt ++ ; } } return cnt ; } let arr = [ 4 , 2 , 1 , 3 , 7 , 8 ] ; let n = arr . length ; document . write ( cntElements ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function xor_triplet ( arr , n ) { let ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { for ( let k = j ; k < n ; k ++ ) { let xor1 = 0 , xor2 = 0 ; for ( let x = i ; x < j ; x ++ ) { xor1 ^= arr [ x ] ; } for ( let x = j ; x <= k ; x ++ ) { xor2 ^= arr [ x ] ; } if ( xor1 == xor2 ) { ans ++ ; } } } } return ans ; } let arr = [ 1 , 2 , 3 , 4 , 5 ] ; let n = arr . length ; document . write ( xor_triplet ( arr , n ) )

Index/key variables: x
Accumulator variables: ans, i, j, k, x, xor1, xor2
Iterator variables: i, j, k, x