dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function Sum ( N ) { let SumOfPrimeDivisors = Array ( N + 1 ) . fill ( 0 ) ; for ( let i = 2 ; i <= N ; ++ i ) { if ( SumOfPrimeDivisors [ i ] == 1 ) { for ( let j = i ; j <= N ; j += i ) { SumOfPrimeDivisors [ j ] += i ; } } } return SumOfPrimeDivisors [ N ] ; } function RuthAaronNumber ( n ) { if ( Sum ( n ) == Sum ( n + 1 ) ) return true ; else return false ; } let N = 714 ; if ( RuthAaronNumber ( N ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Index/key variables: N, i, j
Accumulator variables: j
Iterator variables: i, j
Javascript program:
let mod = 1000000007 ; function linearSum ( n ) { return ( n * ( n + 1 ) / 2 ) % mod ; } function rangeSum ( b , a ) { return ( linearSum ( b ) - linearSum ( a ) ) % mod ; } function totalSum ( n ) { let result = 0 ; let i = 1 ; while ( true ) { result += rangeSum ( Math . floor ( n / i ) , Math . floor ( n / ( i + 1 ) ) ) * ( i % mod ) % mod ; result %= mod ; if ( i == n ) break ; i = Math . floor ( n / ( n / ( i + 1 ) ) ) ; } return result ; } let N = 4 ; document . write ( totalSum ( N ) + " " ) ; N = 12 ; document . write ( totalSum ( N ) ) ;

Accumulator variables: result
Javascript program:
function isDouble ( num ) { let s = num . toString ( ) ; let l = s . length ; if ( s [ 0 ] == s . charAt [ 1 ] ) return false ; if ( l % 2 == 1 ) { s = s + s [ 1 ] ; l ++ ; } let s1 = s . substr ( 0 , l / 2 ) ; let s2 = s . substr ( l / 2 ) ; return ( s1 == s2 ) ; } function isNontrivialUndulant ( N ) { return N > 100 && isDouble ( N ) ; } let n = 121 ; if ( isNontrivialUndulant ( n ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Accumulator variables: l
Javascript program:
mod = 1000000007 function productPairs ( arr , n ) { let product = 1 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { product *= ( arr [ i ] % mod * arr [ j ] % mod ) % mod ; product = product % mod ; } } return product % mod ; } let arr = [ 1 , 2 , 3 ] ; let n = arr . length ; document . write ( productPairs ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, product
Iterator variables: i, j
Javascript program:
let mod = 1000000007 ; function power ( x , y ) { let p = 1000000007 ; let res = 1 ; x = x % p ; while ( y > 0 ) { if ( y % 2 == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } function productPairs ( arr , n ) { let product = 1 ; for ( let i = 0 ; i < n ; i ++ ) { product = ( product % mod * power ( arr [ i ] , ( 2 * n ) ) % mod ) % mod ; } return product % mod ; } let arr = [ 1 , 2 , 3 ] ; let n = arr . length ; document . write ( productPairs ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function constructArray ( N ) { let arr = new Array ( N ) ; for ( let i = 1 ; i <= N ; i ++ ) { arr [ i - 1 ] = i ; } for ( let i = 0 ; i < N ; i ++ ) { document . write ( arr [ i ] + " " ) ; } } let N = 6 ; constructArray ( N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isPrime ( n ) { if ( n <= 1 ) return false ; for ( var i = 2 ; i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } function countSubsequences ( arr , n ) { var totalSubsequence = Math . pow ( 2 , n ) - 1 ; var countPrime = 0 , countOnes = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) countOnes ++ ; else if ( isPrime ( arr [ i ] ) ) countPrime ++ ; } var compositeSubsequence ; var onesSequence = Math . pow ( 2 , countOnes ) - 1 ; compositeSubsequence = totalSubsequence - countPrime - onesSequence - onesSequence * countPrime ; return compositeSubsequence ; } var arr = [ 2 , 1 , 2 ] ; var n = arr . length ; document . write ( countSubsequences ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: countOnes, countPrime, i
Iterator variables: i
Javascript program:
function checksum ( n , k ) { var first_term = ( ( ( 2 * n ) / k + ( 1 - k ) ) / 2.0 ) ; if ( first_term - parseInt ( ( first_term ) ) == 0 ) { for ( i = parseInt ( first_term ) ; i <= first_term + k - 1 ; i ++ ) { document . write ( i + " " ) ; } } else document . write ( " " ) ; } var n = 33 , k = 6 ; checksum ( n , k ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function sumEvenNumbers ( N , K ) { let check = N - 2 * ( K - 1 ) ; if ( check > 0 && check % 2 == 0 ) { for ( let i = 0 ; i < K - 1 ; i ++ ) { document . write ( " " ) ; } document . write ( check ) ; } else { document . write ( " " ) ; } } let N = 8 ; let K = 2 ; sumEvenNumbers ( N , K ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function calculateWays ( n ) { let x = 0 ; let v = Array . from ( { length : n } , ( _ , i ) => 0 ) ; for ( let i = 0 ; i < n ; i ++ ) v [ i ] = 0 ; for ( let i = 0 ; i < n / 2 ; i ++ ) { if ( n % 2 == 0 && i == n / 2 ) break ; x = n * ( i + 1 ) - ( i + 1 ) * i ; v [ i ] = x ; v [ n - i - 1 ] = x ; } return v ; } function prletArray ( v ) { for ( let i = 0 ; i < v . length ; i ++ ) document . write ( v [ i ] + " " ) ; } let v ; v = calculateWays ( 4 ) ; prletArray ( v ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var MAXN = 10000000 ; function sumOfDigits ( n ) { var sum = 0 ; while ( n > 0 ) { sum += n % 10 ; n = parseInt ( n / 10 ) ; } return sum ; } function smallestNum ( X , Y ) { var res = - 1 ; for ( i = X ; i < MAXN ; i ++ ) { var sum_of_digit = sumOfDigits ( i ) ; if ( sum_of_digit % Y == 0 ) { res = i ; break ; } } return res ; } var X = 5923 , Y = 13 ; document . write ( smallestNum ( X , Y ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function countValues ( N ) { var div = [ ] ; for ( var i = 2 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { div . push ( i ) ; if ( N != i * i ) { div . push ( N / i ) ; } } } var answer = 0 ; for ( var i = 1 ; i * i <= N - 1 ; i ++ ) { if ( ( N - 1 ) % i == 0 ) { if ( i * i == N - 1 ) answer ++ ; else answer += 2 ; } } div . forEach ( d => { var K = N ; while ( K % d == 0 ) K /= d ; if ( ( K - 1 ) % d == 0 ) answer ++ ; } ) ; return answer ; } var N = 6 ; document . write ( countValues ( N ) ) ;

Accumulator variables: K, answer, i
Iterator variables: i
Javascript program:
function findMaxPrimeDivisor ( n ) { let max_possible_prime = 0 ; while ( n % 2 == 0 ) { max_possible_prime ++ ; n = Math . floor ( n / 2 ) ; } for ( let i = 3 ; i * i <= n ; i = i + 2 ) { while ( n % i == 0 ) { max_possible_prime ++ ; n = Math . floor ( n / i ) ; } } if ( n > 2 ) { max_possible_prime ++ ; } document . write ( max_possible_prime + " " ) ; } let n = 4 ; findMaxPrimeDivisor ( n ) ;

Accumulator variables: max_possible_prime
Iterator variables: i
Javascript program:
function Solve ( arr , size , n ) { let v = Array . from ( { length : n + 1 } , ( _ , i ) => 0 ) ; for ( let i = 0 ; i < size ; i ++ ) v [ arr [ i ] ] ++ ; let max1 = - 1 , mx = - 1 ; for ( let i = 0 ; i < v . length ; i ++ ) { if ( v [ i ] > mx ) { mx = v [ i ] ; max1 = i ; } } let cnt = 0 ; for ( let i in v ) { if ( i == 0 ) ++ cnt ; } let diff1 = n + 1 - cnt ; let max_size = Math . max ( Math . min ( v [ max1 ] - 1 , diff1 ) , Math . min ( v [ max1 ] , diff1 - 1 ) ) ; document . write ( " " + max_size + " " ) ; document . write ( " " + " " ) ; for ( let i = 0 ; i < max_size ; i ++ ) { document . write ( max1 + " " ) ; v [ max1 ] -= 1 ; } document . write ( " " ) ; document . write ( " " + " " ) ; for ( let i = 0 ; i < ( n + 1 ) ; i ++ ) { if ( v [ i ] > 0 ) { document . write ( i + " " ) ; max_size -- ; } if ( max_size < 1 ) break ; } document . write ( " " ) ; } let n = 7 ; let arr = [ 1 , 2 , 1 , 5 , 1 , 6 , 7 , 2 ] ; let size = arr . length ; Solve ( arr , size , n ) ;

Index/key variables: i, max1
Accumulator variables: i, max_size
Iterator variables: i
Javascript program:
function power ( x , y , p ) { let res = 1 ; x = x % p ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } function modInverse ( n , p ) { return power ( n , p - 2 , p ) ; } function nCrModPFermat ( n , r , p ) { if ( r == 0 ) return 1 ; if ( n < r ) return 0 ; let fac = Array . from ( { length : n + 1 } , ( _ , i ) => 0 ) ; fac [ 0 ] = 1 ; for ( let i = 1 ; i <= n ; i ++ ) fac [ i ] = fac [ i - 1 ] * i % p ; return ( fac [ n ] * modInverse ( fac [ r ] , p ) % p * modInverse ( fac [ n - r ] , p ) % p ) % p ; } function SumOfXor ( a , n ) { let mod = 10037 ; let answer = 0 ; for ( let k = 0 ; k < 32 ; k ++ ) { let x = 0 , y = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( ( a [ i ] & ( 1 << k ) ) != 0 ) x ++ ; else y ++ ; } answer += ( ( 1 << k ) % mod * ( nCrModPFermat ( x , 3 , mod ) + x * nCrModPFermat ( y , 2 , mod ) ) % mod ) % mod ; } return answer ; } let n = 5 ; let A = [ 3 , 5 , 2 , 18 , 7 ] ; document . write ( SumOfXor ( A , n ) ) ;

Index/key variables: i, n, r
Accumulator variables: answer, i, k, x, y
Iterator variables: i, k
Javascript program:
function round ( vr , digit ) { var value = parseInt ( ( vr * Math . pow ( 10 , digit ) + .5 ) ) ; return value / Math . pow ( 10 , digit ) ; } function probability ( N ) { var a = 2 ; var b = 3 ; if ( N == 1 ) { return a ; } else if ( N == 2 ) { return b ; } else { for ( i = 3 ; i <= N ; i ++ ) { var c = a + b ; a = b ; b = c ; } return b ; } } function operations ( N ) { var x = probability ( N ) ; var y = parseInt ( Math . pow ( 2 , N ) ) ; return round ( x / y , 2 ) ; } var N = 10 ; document . write ( ( operations ( N ) ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function largest_sum ( arr , n ) { let maximum = - 1 ; let m = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( m . has ( arr [ i ] ) ) { m . set ( arr [ i ] , m . get ( arr [ i ] ) + 1 ) ; } else { m . set ( arr [ i ] , 1 ) ; } } for ( let i = 0 ; i < n ; i ++ ) { if ( m . get ( arr [ i ] ) > 1 ) { if ( m . has ( 2 * arr [ i ] ) ) { m . set ( 2 * arr [ i ] , m . get ( 2 * arr [ i ] ) + m . get ( arr [ i ] ) / 2 ) ; } else { m . set ( 2 * arr [ i ] , m . get ( arr [ i ] ) / 2 ) ; } if ( 2 * arr [ i ] > maximum ) maximum = 2 * arr [ i ] ; } } return maximum ; } let arr = [ 1 , 1 , 2 , 4 , 7 , 8 ] ; let n = arr . length ; document . write ( largest_sum ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isPrime ( N ) { let isPrime = true ; let arr = [ 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 ] ; if ( N < 2 ) { isPrime = false ; } if ( N % 2 == 0 N % 3 == 0 N % 5 == 0 ) { isPrime = false ; } for ( let i = 0 ; i < Math . sqrt ( N ) ; i += 30 ) { for ( let c of arr ) { if ( c > Math . sqrt ( N ) ) { break ; } else { if ( N % ( c + i ) == 0 ) { isPrime = false ; break ; } } if ( ! isPrime ) break ; } } if ( isPrime ) document . write ( " " ) ; else document . write ( " " ) ; } let N = 121 ; isPrime ( N ) ;

Accumulator variables: i
Iterator variables: c, i
Boolean variables: isPrime
Javascript program:
function printPairs ( arr , n ) { for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j < n ; j ++ ) { document . write ( " " + arr [ i ] + " " + arr [ j ] + " " + " " ) ; } } } var arr = [ 1 , 2 ] ; var n = arr . length ; printPairs ( arr , n ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function polygonArea ( X , Y , n ) { let area = 0.0 ; let j = n - 1 ; for ( let i = 0 ; i < n ; i ++ ) { area += ( X [ j ] + X [ i ] ) * ( Y [ j ] - Y [ i ] ) ; } return Math . abs ( area / 2.0 ) ; } let X = [ 0 , 2 , 4 ] ; let Y = [ 1 , 3 , 7 ] ; let n = X . length ; document . write ( polygonArea ( X , Y , n ) ) ;

Index/key variables: i, j
Accumulator variables: area, i
Iterator variables: i
Javascript program:
const chk = ( n ) => { let v = [ ] ; while ( n != 0 ) { v . push ( n % 2 ) ; n = parseInt ( n / 2 ) ; } for ( let i = 0 ; i < v . length ; i ++ ) { if ( v [ i ] == 1 ) { return Math . pow ( 2 , i ) ; } } return 0 ; } const sumOfLSB = ( arr , N ) => { let lsb_arr = [ ] ; for ( let i = 0 ; i < N ; i ++ ) { lsb_arr . push ( chk ( arr [ i ] ) ) ; } lsb_arr . sort ( ( a , b ) => a - b ) let ans = 0 ; for ( let i = 0 ; i < N - 1 ; i += 2 ) { ans += ( lsb_arr [ i + 1 ] ) ; } document . write ( ans ) ; } let N = 5 ; let arr = [ 1 , 2 , 3 , 4 , 5 ] ; sumOfLSB ( arr , N ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function countSubsequences ( arr ) { let odd = 0 ; for ( let x = 0 ; x < arr . length ; x ++ ) { if ( arr [ x ] & 1 ) odd ++ ; } return ( 1 << odd ) - 1 ; } let arr = [ 1 , 3 , 3 ] ; document . write ( countSubsequences ( arr ) ) ;

Index/key variables: x
Accumulator variables: odd, x
Iterator variables: x
Javascript program:
function getPairsCount ( arr , n ) { let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = arr [ i ] - ( i % arr [ i ] ) ; j < n ; j += arr [ i ] ) { if ( i < j && Math . abs ( arr [ i ] - arr [ j ] ) >= Math . min ( arr [ i ] , arr [ j ] ) ) { count ++ ; } } } return count ; } let arr = [ 1 , 2 , 2 , 3 ] ; let N = arr . length ; document . write ( getPairsCount ( arr , N ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function check ( N ) { var twos = 0 , fives = 0 ; while ( N % 2 == 0 ) { N /= 2 ; twos ++ ; } while ( N % 5 == 0 ) { N /= 5 ; fives ++ ; } if ( N == 1 && twos <= fives ) { document . write ( 2 * fives - twos ) ; } else { document . write ( - 1 ) ; } } var N = 50 ; check ( N ) ;

Accumulator variables: N, fives, twos
Javascript program:
function rangeSum ( arr , N , L , R ) { let sum = 0 ; for ( let i = L - 1 ; i < R ; i ++ ) { sum += arr [ i % N ] ; } document . write ( sum ) ; } let arr = [ 5 , 2 , 6 , 9 ] ; let L = 10 , R = 13 ; let N = arr . length rangeSum ( arr , N , L , R ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function rangeSum ( arr , N , L , R ) { let prefix = new Array ( N + 1 ) ; prefix [ 0 ] = 0 ; for ( let i = 1 ; i <= N ; i ++ ) { prefix [ i ] = prefix [ i - 1 ] + arr [ i - 1 ] ; } let leftsum = ( ( L - 1 ) / N ) * prefix [ N ] + prefix [ ( L - 1 ) % N ] ; let rightsum = ( R / N ) * prefix [ N ] + prefix [ R % N ] ; document . write ( rightsum - leftsum ) ; } let arr = [ 5 , 2 , 6 , 9 ] ; let L = 10 , R = 13 ; let N = arr . length ; rangeSum ( arr , N , L , R ) ;

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function ExpoFactorial ( N ) { let res = 1 ; let mod = 1000000007 ; for ( let i = 2 ; i < N + 1 ; i ++ ) res = Math . pow ( i , res ) % mod ; return res ; } let N = 4 ; document . write ( ( ExpoFactorial ( N ) ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function maxSubArraySumRepeated ( arr , N , K ) { let sum = 0 ; for ( let i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; let curr = arr [ 0 ] ; let ans = arr [ 0 ] ; if ( K == 1 ) { for ( let i = 1 ; i < N ; i ++ ) { curr = Math . max ( arr [ i ] , curr + arr [ i ] ) ; ans = Math . max ( ans , curr ) ; } return ans ; } let V = [ ] ; for ( let i = 0 ; i < 2 * N ; i ++ ) { V . push ( arr [ i % N ] ) ; } let maxSuf = V [ 0 ] ; let maxPref = V [ 2 * N - 1 ] ; curr = V [ 0 ] ; for ( let i = 1 ; i < 2 * N ; i ++ ) { curr += V [ i ] ; maxPref = Math . max ( maxPref , curr ) ; } curr = V [ 2 * N - 1 ] ; for ( let i = 2 * N - 2 ; i >= 0 ; i -- ) { curr += V [ i ] ; maxSuf = Math . max ( maxSuf , curr ) ; } curr = V [ 0 ] ; for ( let i = 1 ; i < 2 * N ; i ++ ) { curr = Math . max ( V [ i ] , curr + V [ i ] ) ; ans = Math . max ( ans , curr ) ; } if ( sum > 0 ) { let temp = sum * ( K - 2 ) ; ans = Math . max ( ans , Math . max ( temp + maxPref , temp + maxSuf ) ) ; } return ans ; } let arr = [ 10 , 20 , - 30 , - 1 , 40 ] ; let N = arr . length ; let K = 10 ; document . write ( maxSubArraySumRepeated ( arr , N , K ) ) ;

Index/key variables: i
Accumulator variables: curr, i, sum
Iterator variables: i
Javascript program:
function countSubarray ( arr , n ) { let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i ; j < n ; j ++ ) { let mxSubarray = 0 ; let mxOther = 0 ; for ( let k = i ; k <= j ; k ++ ) { mxSubarray = Math . max ( mxSubarray , arr [ k ] ) ; } for ( let k = 0 ; k < i ; k ++ ) { mxOther = Math . max ( mxOther , arr [ k ] ) ; } for ( let k = j + 1 ; k < n ; k ++ ) { mxOther = Math . max ( mxOther , arr [ k ] ) ; } if ( mxSubarray > ( 2 * mxOther ) ) count ++ ; } } document . write ( count ) ; } let arr = [ 1 , 6 , 10 , 9 , 7 , 3 ] ; let N = arr . length ; countSubarray ( arr , N ) ;

Index/key variables: k
Accumulator variables: count, i, j, k
Iterator variables: i, j, k
Javascript program:
function countSubarray ( arr , n ) { var count = 0 , L = 0 , R = 0 ; var mx = Math . max . apply ( null , arr ) ; var i ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] * 2 > mx ) { L = i ; break ; } } for ( i = n - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] * 2 > mx ) { R = i ; break ; } } document . write ( ( L + 1 ) * ( n - R ) ) ; } var arr = [ 1 , 6 , 10 , 9 , 7 , 3 ] var N = arr . length ; countSubarray ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isPrime ( X ) { for ( let i = 2 ; i * i <= X ; i ++ ) return false ; return true ; } function printPrimes ( A , N ) { for ( let i = 0 ; i < N ; i ++ ) { for ( let j = A [ i ] - 1 ; ; j -- ) { if ( isPrime ( j ) ) { document . write ( j + " " ) ; break ; } } for ( let j = A [ i ] + 1 ; ; j ++ ) { if ( isPrime ( j ) ) { document . write ( j + " " ) ; break ; } } document . write ( " " ) ; } } let A = [ 17 , 28 ] ; let N = A . length ; printPrimes ( A , N ) ;

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function KthSmallest ( A , B , N , K ) { let M = 0 ; for ( let i = 0 ; i < N ; i ++ ) { M = Math . max ( A [ i ] , M ) ; } let freq = Array . from ( { length : M + 1 } , ( _ , i ) => 0 ) ; for ( let i = 0 ; i < N ; i ++ ) { freq [ A [ i ] ] += B [ i ] ; } let sum = 0 ; for ( let i = 0 ; i <= M ; i ++ ) { sum += freq [ i ] ; if ( sum >= K ) { return i ; } } return - 1 ; } let A = [ 3 , 4 , 5 ] ; let B = [ 2 , 1 , 3 ] ; let N = A . length ; let K = 4 ; document . write ( KthSmallest ( A , B , N , K ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function findbitwiseOR ( a , n ) { let res = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let curr_sub_array = a [ i ] ; res = res | curr_sub_array ; for ( let j = i ; j < n ; j ++ ) { curr_sub_array = curr_sub_array & a [ j ] ; res = res | curr_sub_array ; } } document . write ( res ) ; } let A = [ 1 , 2 , 3 ] ; let N = A . length ; findbitwiseOR ( A , N ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function findbitwiseOR ( a , n ) { var res = 0 ; var i ; for ( i = 0 ; i < n ; i ++ ) res = res | a [ i ] ; document . write ( res ) ; } var A = [ 1 , 2 , 3 ] ; var N = A . length ; findbitwiseOR ( A , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function check ( n ) { let sumOfDigit = 0 ; let prodOfDigit = 1 ; while ( n > 0 ) { let rem ; rem = n % 10 ; sumOfDigit += rem ; prodOfDigit *= rem ; n = Math . floor ( n / 10 ) ; } if ( sumOfDigit > prodOfDigit ) document . write ( " " ) ; else document . write ( " " ) ; } let N = 1234 ; check ( N ) ;

Accumulator variables: prodOfDigit, sumOfDigit
Javascript program:
function evenOddBitwiseXOR ( N ) { document . write ( " " + 0 + " " ) ; for ( let i = 4 ; i <= N ; i = i + 4 ) { document . write ( i + " " ) ; } document . write ( " " ) ; document . write ( " " + 1 + " " ) ; for ( let i = 4 ; i <= N ; i = i + 4 ) { document . write ( i - 1 + " " ) ; } if ( N % 4 == 2 ) document . write ( N + 1 ) ; else if ( N % 4 == 3 ) document . write ( N ) ; } let N = 6 ; evenOddBitwiseXOR ( N ) ;

Iterator variables: i
Javascript program:
function findPermutation ( arr ) { let N = arr . length ; let i = N - 2 ; while ( i >= 0 && arr [ i ] <= arr [ i + 1 ] ) i -- ; if ( i == - 1 ) { document . write ( " " ) ; return ; } let j = N - 1 ; while ( j > i && arr [ j ] >= arr [ i ] ) j -- ; while ( j > i && arr [ j ] == arr [ j - 1 ] ) { j -- ; } let temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; for ( let it in arr ) { document . write ( arr [ it ] + " " ) ; } } let arr = [ 1 , 2 , 5 , 3 , 4 , 6 ] ; findPermutation ( arr ) ;

Index/key variables: i, it, j
Accumulator variables: i, j
Iterator variables: it
Javascript program:
function sieveOfEratosthenes ( N , s ) { let prime = Array . from ( { length : N + 1 } , ( _ , i ) => 0 ) ; for ( let i = 2 ; i <= N ; i += 2 ) s [ i ] = 2 ; for ( let i = 3 ; i <= N ; i += 2 ) { if ( prime [ i ] == false ) { s [ i ] = i ; for ( let j = i ; j * i <= N ; j += 2 ) { if ( ! prime [ i * j ] ) { prime [ i * j ] = true ; s [ i * j ] = i ; } } } } } function findDifference ( N ) { let s = Array . from ( { length : N + 1 } , ( _ , i ) => 0 ) ; sieveOfEratosthenes ( N , s ) ; let total = 1 , odd = 1 , even = 0 ; let curr = s [ N ] ; let cnt = 1 ; while ( N > 1 ) { N /= s [ N ] ; if ( curr == s [ N ] ) { cnt ++ ; continue ; } if ( curr == 2 ) { total = total * ( cnt + 1 ) ; } else { total = total * ( cnt + 1 ) ; odd = odd * ( cnt + 1 ) ; } curr = s [ N ] ; cnt = 1 ; } even = total - odd ; document . write ( Math . abs ( even - odd ) ) ; } let N = 12 ; findDifference ( N ) ;

Index/key variables: N, i
Accumulator variables: N, cnt, i, j
Iterator variables: i, j
Javascript program:
function perfectSquare ( num ) { let sr = Math . floor ( Math . sqrt ( num ) ) ; let a = sr * sr ; let b = ( sr + 1 ) * ( sr + 1 ) ; if ( ( num - a ) < ( b - num ) ) { return a ; } else { return b ; } } function powerOfTwo ( num ) { let lg = Math . floor ( Math . log2 ( num ) ) ; let p = Math . pow ( 2 , lg ) ; return p ; } function uniqueElement ( arr , N ) { let ans = true ; arr . reverse ( ) ; let freq = new Map ( ) ; for ( let i = 0 ; i < N ; i ++ ) { freq [ arr [ i ] ] ++ ; if ( freq . has ( arr [ i ] ) ) { freq . set ( arr [ i ] , freq . get ( arr [ i ] ) + 1 ) } else [ freq . set ( arr [ i ] , 1 ) ] } for ( let el of freq ) { if ( el [ 1 ] == 1 ) { ans = false ; let ps = perfectSquare ( el [ 0 ] ) ; document . write ( powerOfTwo ( ps ) + ' ' ) ; } } if ( ans ) document . write ( " " ) ; } let arr = [ 4 , 11 , 4 , 3 , 4 ] ; let N = arr . length ; uniqueElement ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: el, i
Boolean variables: ans
Javascript program:
function partitionArray ( a , n ) { var min = Array ( n ) . fill ( 0 ) ; var mini = Number . MAX_VALUE ; for ( i = n - 1 ; i >= 0 ; i -- ) { mini = Math . min ( mini , a [ i ] ) ; min [ i ] = mini ; } var maxi = Number . MIN_VALUE ; var ind = - 1 ; for ( i = 0 ; i < n - 1 ; i ++ ) { maxi = Math . max ( maxi , a [ i ] ) ; if ( maxi < min [ i + 1 ] ) { ind = i ; break ; } } if ( ind != - 1 ) { for ( i = 0 ; i <= ind ; i ++ ) document . write ( a [ i ] + " " ) ; document . write ( " " ) ; for ( i = ind + 1 ; i < n ; i ++ ) document . write ( a [ i ] + " " ) ; } else document . write ( " " ) ; } var arr = [ 5 , 3 , 2 , 7 , 9 ] ; var N = arr . length ; partitionArray ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countPrimeFactors ( n ) { var count = 0 ; while ( n % 2 == 0 ) { n = parseInt ( n / 2 ) ; count ++ ; } for ( i = 3 ; i <= parseInt ( Math . sqrt ( n ) ) ; i = i + 2 ) { while ( n % i == 0 ) { n = parseInt ( n / i ) ; count ++ ; } } if ( n > 2 ) count ++ ; return ( count ) ; } function findSum ( n ) { var sum = 0 ; for ( i = 1 , num = 2 ; i <= n ; num ++ ) { if ( countPrimeFactors ( num ) == 2 ) { sum += num ; i ++ ; } } return sum ; } function check ( n , k ) { var s = findSum ( k - 1 ) ; if ( s >= n ) document . write ( " " ) ; else document . write ( " " ) ; } var n = 100 , k = 6 ; check ( n , k ) ;

Accumulator variables: count, i, num, sum
Iterator variables: i