dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function calculateLnx ( n ) { let num , mul , cal , sum = 0 ; num = ( n - 1 ) / ( n + 1 ) ; for ( let i = 1 ; i <= 1000 ; i ++ ) { mul = ( 2 * i ) - 1 ; cal = Math . pow ( num , mul ) ; cal = cal / mul ; sum = sum + cal ; } sum = 2 * sum ; return sum ; } function calculateLogx ( lnx ) { return ( lnx / 2.303 ) ; } let lnx , logx , n = 5 ; lnx = calculateLnx ( n ) ; logx = calculateLogx ( lnx ) ; document . write ( " " + n + " " + lnx + " " ) ; document . write ( " " + n + " " + logx + " " ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function sum ( A , B , R ) { let sum = 0 ; for ( let i = 1 ; i <= R ; i ++ ) { sum = sum + ( i * A ) ; A = A + B ; } return sum ; } let A = 5 , B = 3 , R = 3 ; document . write ( sum ( A , B , R ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function countSetBits ( n ) { n ++ ; var powerOf2 = 2 ; var cnt = n / 2 ; while ( powerOf2 <= n ) { var totalPairs = n / powerOf2 ; cnt += ( totalPairs / 2 ) * powerOf2 ; cnt += ( totalPairs % 2 == 1 ) ? ( n % powerOf2 ) : 0 ; powerOf2 <<= 1 ; } return cnt ; } var n = 14 ; document . write ( countSetBits ( n ) ) ;

Accumulator variables: cnt, n
Javascript program:
function NoofTriplets ( N , K ) { let cnt = Array ( K ) ; for ( let i = 0 ; i < K ; i ++ ) cnt [ i ] = 0 ; for ( let i = 1 ; i <= N ; i += 1 ) { cnt [ i % K ] += 1 ; } if ( K & 1 ) return cnt [ 0 ] * cnt [ 0 ] * cnt [ 0 ] ; else { return ( cnt [ 0 ] * cnt [ 0 ] * cnt [ 0 ] + cnt [ K / 2 ] * cnt [ K / 2 ] * cnt [ K / 2 ] ) ; } } let N = 3 ; let K = 2 ; document . write ( NoofTriplets ( N , K ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function GCD ( a , b ) { if ( b == 0 ) return a ; return GCD ( b , a % b ) ; } function findReachable ( arr , D , A , B , n ) { var gcd_AB = GCD ( A , B ) ; var count = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] - D ) % gcd_AB == 0 ) count ++ ; } return count ; } var arr = [ 4 , 5 , 6 , 7 , 8 , 9 ] ; var n = arr . length ; var D = 4 , A = 4 , B = 6 ; document . write ( findReachable ( arr , D , A , B , n ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function getfactor ( n , p ) { let pw = 0 ; while ( n != 0 ) { n = parseInt ( n / p , 10 ) ; pw += n ; } return pw ; } function isDivisible ( n , r , p ) { let x1 = getfactor ( n , p ) ; let x2 = getfactor ( r , p ) ; let x3 = getfactor ( n - r , p ) ; if ( x1 > x2 + x3 ) return 1 ; return 0 ; } let n = 7 , r = 2 , p = 7 ; if ( isDivisible ( n , r , p ) == 1 ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: pw
Javascript program:
function isEven ( arr , n , r ) { if ( r % 2 == 0 ) { if ( arr [ n - 1 ] % 2 == 0 ) return true ; } else { let oddCount = 0 ; for ( let i = 0 ; i < n ; ++ i ) { if ( arr [ i ] % 2 != 0 ) oddCount ++ ; } if ( oddCount % 2 == 0 ) return true ; } return false ; } let arr = [ 1 , 0 ] ; let n = arr . length ; let r = 2 ; if ( isEven ( arr , n , r ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: oddCount
Iterator variables: i
Javascript program:
function closetAND ( arr , n , k ) { let ans = Number . MAX_VALUE ; for ( let i = 0 ; i < n ; i ++ ) { let X = arr [ i ] ; for ( let j = i ; j < n ; j ++ ) { X &= arr [ j ] ; ans = Math . min ( ans , Math . abs ( k - X ) ) ; if ( X <= k ) break ; } } return ans ; } let arr = [ 4 , 7 , 10 ] ; let n = arr . length ; let k = 2 ; document . write ( closetAND ( arr , n , k ) ) ;

Index/key variables: i, j
Accumulator variables: X, i, j
Iterator variables: i, j
Javascript program:
function gcd ( a , b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } function countQuadruplets ( l , r , k ) { let frequency = new Array ( r + 1 ) ; frequency . fill ( 0 ) ; for ( let i = l ; i <= r ; i ++ ) { for ( let j = l ; j <= r ; j ++ ) { frequency [ gcd ( i , j ) ] ++ ; } } let answer = 0 ; for ( let i = 1 ; i <= r ; i ++ ) { for ( let j = 1 ; j <= r ; j ++ ) { if ( gcd ( i , j ) == k ) { answer += ( frequency [ i ] * frequency [ j ] ) ; } } } return answer ; } let l = 1 , r = 10 , k = 2 ; document . write ( countQuadruplets ( l , r , k ) ) ;

Index/key variables: i, j
Accumulator variables: answer, i, j
Iterator variables: i, j
Javascript program:
function solve ( a , n ) { let ones = 0 , twos = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 1 ) ones ++ ; else twos ++ ; } let ind = 0 ; if ( twos > 0 ) a [ ind ++ ] = 2 ; let evenOnes = ( ones % 2 == 0 ) ? true : false ; if ( evenOnes ) ones -= 1 ; for ( let i = 0 ; i < ones ; i ++ ) a [ ind ++ ] = 1 ; for ( let i = 0 ; i < twos - 1 ; i ++ ) a [ ind ++ ] = 2 ; if ( evenOnes ) a [ ind ++ ] = 1 ; for ( let i = 0 ; i < n ; i ++ ) document . write ( a [ i ] + " " ) ; } let a = [ 1 , 2 , 1 , 2 , 1 ] ; let n = a . length ; solve ( a , n ) ;

Index/key variables: i
Accumulator variables: i, ind, ones, twos
Iterator variables: i
Javascript program:
function CreateArray ( N , even , odd ) { let EvenPreSums = 1 ; let temp = - 1 ; let OddPreSums = 0 ; for ( let i = 0 ; i <= N + 1 ; i ++ ) { if ( i * ( ( N + 1 ) - i ) == odd ) { temp = 0 ; OddPreSums = i ; break ; } } if ( temp == - 1 ) { document . write ( temp ) ; } else { EvenPreSums = ( ( N + 1 ) - OddPreSums ) ; let e = 1 ; let o = 0 ; let CurrSum = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( CurrSum % 2 == 0 ) { if ( e < EvenPreSums ) { e ++ ; document . write ( " " ) ; } else { o ++ ; document . write ( " " ) ; CurrSum ++ ; } } else { if ( e < EvenPreSums ) { e ++ ; document . write ( " " ) ; CurrSum ++ ; } else { o ++ ; document . write ( " " ) ; } } } document . write ( ) ; } } let N = 15 ; let even = 60 , odd = 60 ; CreateArray ( N , even , odd ) ;

Accumulator variables: CurrSum, e, i, o
Iterator variables: i
Javascript program:
function changeTheArray ( arr , n ) { let minEle = Math . min ( ... arr ) ; let maxEle = Math . max ( ... arr ) ; let minOperations = Number . MAX_VALUE ; for ( let num = minEle ; num <= maxEle ; num ++ ) { let operations = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != num ) { operations += ( Math . abs ( num - arr [ i ] ) - 1 ) ; } } minOperations = Math . min ( minOperations , operations ) ; } return minOperations ; } let arr = [ 10 , 1 , 4 ] ; let n = arr . length ; document . write ( changeTheArray ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i, num, operations
Iterator variables: i, num
Javascript program:
function findX ( A , B ) { let j = 0 , x = 0 ; while ( A != 0 B != 0 ) { if ( ( A % 2 == 1 ) && ( B % 2 == 1 ) ) { x += ( 1 << j ) ; } A >>= 1 ; B >>= 1 ; j += 1 ; } return x ; } let A = 2 , B = 3 ; let X = findX ( A , B ) ; document . write ( " " + X + " " + ( ( A ^ X ) + ( B ^ X ) ) ) ;

Accumulator variables: j, x
Javascript program:
function isSumEqual ( ar , n ) { let sum = 0 ; for ( let i = 0 ; i < n - 1 ; i ++ ) sum += ar [ i ] ; if ( sum == ar [ n - 1 ] ) return true ; return false ; } let arr = [ 1 , 2 , 3 , 4 , 10 ] ; let n = arr . length ; if ( isSumEqual ( arr , n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function printPosition ( A , B , sizeOfA , sizeOfB ) { for ( i = 1 ; i < sizeOfA ; i ++ ) { A [ i ] += A [ i - 1 ] ; } for ( i = 0 ; i < sizeOfB ; i ++ ) { var row = lower_bound ( A , 0 , A . length , B [ i ] ) ; var boxNumber = ( row >= 1 ) ? B [ i ] - A [ row - 1 ] : B [ i ] ; document . write ( row + 1 + " " + boxNumber + " " ) ; } } function lower_bound ( a , low , high , element ) { while ( low < high ) { var middle = low + ( high - low ) / 2 ; if ( element > a [ middle ] ) { low = middle + 1 ; } else { high = middle ; } } return low ; } var A = [ 2 , 2 , 2 , 2 ] ; var B = [ 1 , 2 , 3 , 4 ] ; var sizeOfA = A . length ; var sizeOfB = B . length ; printPosition ( A , B , sizeOfA , sizeOfB ) ;

Index/key variables: i, middle
Accumulator variables: i
Iterator variables: i
Javascript program:
function primeFactors ( n , freq ) { var cnt = 0 ; while ( n % 2 == 0 ) { cnt ++ ; n = n / 2 ; } freq [ 2 ] = cnt ; var i ; for ( i = 3 ; i <= Math . sqrt ( n ) ; i = i + 2 ) { cnt = 0 ; while ( n % i == 0 ) { cnt ++ ; n = n / i ; } freq [ i ] = cnt ; } if ( n > 2 ) freq [ n ] = 1 ; } function getMaximumPower ( n , m ) { var freq1 = new Array ( n + 1 ) ; var freq2 = new Array ( m + 1 ) ; primeFactors ( n , freq1 ) ; primeFactors ( m , freq2 ) ; var maxi = 0 ; for ( i = 2 ; i <= m ; i ++ ) { if ( freq1 [ i ] == 0 && freq2 [ i ] == 0 ) continue ; if ( freq2 [ i ] > freq1 [ i ] ) return 0 ; if ( freq2 [ i ] ) { maxi = Math . max ( maxi , freq1 [ i ] / freq2 [ i ] ) ; } } return maxi ; } var n = 48 , m = 4 ; document . write ( getMaximumPower ( n , m ) ) ;

Index/key variables: i, n
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function findDivisors ( n ) { let div = new Array ( n + 1 ) . fill ( 0 ) ; for ( let i = 1 ; i <= n ; i ++ ) { for ( let j = 1 ; j * i <= n ; j ++ ) div [ i * j ] ++ ; } for ( let i = 1 ; i <= n ; i ++ ) document . write ( div [ i ] + " " ) ; } let n = 10 ; findDivisors ( n ) ;

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function decideWinner ( a , n ) { var count0 = 0 ; var count1 = 0 ; var count2 = 0 ; var count3 = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 4 == 0 ) count0 ++ ; else if ( a [ i ] % 4 == 1 ) count1 ++ ; else if ( a [ i ] % 4 == 2 ) count2 ++ ; else if ( a [ i ] % 4 == 3 ) count3 ++ ; } if ( count0 % 2 == 0 && count1 % 2 == 0 && count2 % 2 == 0 && count3 == 0 ) return 1 ; else return 2 ; } var a = [ 4 , 8 , 5 , 9 ] ; var n = a . length ; if ( decideWinner ( a , n ) == 1 ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: count0, count1, count2, count3, i
Iterator variables: i
Javascript program:
function CntDivbyX ( arr , n , x ) { let number = 0 ; let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { number = ( number * 2 + arr [ i ] ) % x ; if ( number == 0 ) count += 1 ; } return count ; } let arr = [ 1 , 0 , 1 , 0 , 1 , 1 , 0 ] ; let n = arr . length ; let x = 2 ; document . write ( CntDivbyX ( arr , n , x ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function numLen ( K ) { if ( K % 2 == 0 K % 5 == 0 ) return - 1 ; var number = 0 ; var len = 1 ; for ( len = 1 ; len <= K ; len ++ ) { number = ( number * 10 + 1 ) % K ; if ( number == 0 ) return len ; } return - 1 ; } var K = 7 ; document . write ( numLen ( K ) ) ;

Accumulator variables: len
Iterator variables: len
Javascript program:
var max_Element = 1e6 + 5 ; var sum1 = new Array ( max_Element ) . fill ( 0 ) ; var sum2 = new Array ( max_Element ) . fill ( 0 ) ; var sum3 = new Array ( max_Element ) . fill ( 0 ) ; function precomputation ( arr , n ) { for ( var i = 1 ; i < max_Element ; i ++ ) for ( var j = i ; j < max_Element ; j += i ) sum1 [ j ] += i ; for ( var i = 1 ; i < max_Element ; i ++ ) for ( var j = i ; j < max_Element ; j += i ) sum2 [ j ] += ( sum1 [ j ] - i ) * i ; for ( var i = 1 ; i < max_Element ; i ++ ) sum2 [ i ] /= 2 ; for ( var i = 1 ; i < max_Element ; i ++ ) for ( var j = i ; j < max_Element ; j += i ) sum3 [ j ] += i * ( sum2 [ j ] - i * ( sum1 [ j ] - i ) ) ; for ( var i = 1 ; i < max_Element ; i ++ ) sum3 [ i ] /= 3 ; for ( var i = 0 ; i < n ; i ++ ) document . write ( sum3 [ arr [ i ] ] + " " ) ; } var arr = [ 9 , 5 , 6 ] ; var n = 3 ; precomputation ( arr , n ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function printBalancedExpression ( a , b , c , d ) { if ( ( ( a == d ) && ( a != 0 ) ) || ( ( a == 0 ) && ( c == 0 ) && ( d == 0 ) ) ) { for ( i = 1 ; i <= a ; i ++ ) document . write ( " " ) ; for ( i = 1 ; i <= c ; i ++ ) document . write ( " " ) ; for ( i = 1 ; i <= d ; i ++ ) document . write ( " " ) ; for ( i = 1 ; i <= b ; i ++ ) document . write ( " " ) ; } else document . write ( - 1 ) ; } var a = 3 , b = 1 , c = 4 , d = 3 ; printBalancedExpression ( a , b , c , d ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function factorial ( f ) { var fact = 1 ; for ( var i = 2 ; i <= f ; i ++ ) fact *= i ; return fact ; } function findPermutation ( N , M ) { var permutation = factorial ( N + M - 1 ) / ( factorial ( N ) * factorial ( M - 1 ) ) ; return permutation ; } var N = 3 , M = 3 ; document . write ( findPermutation ( N , M ) ) ;

Accumulator variables: fact, i
Iterator variables: i
Javascript program:
function findCount ( n ) { var a = 1 , b = 0 , c = 0 ; var x = parseInt ( n / 60 ) ; a = Math . pow ( 32 , x ) ; x = 60 * x ; for ( i = x + 1 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) { b += a ; a = 0 ; } if ( i % 5 == 0 ) { c += b ; b = 0 ; } if ( i % 12 == 0 ) { a += ( 2 * c ) ; c = 0 ; } } document . write ( " " + a + " " + b + " " + c ) ; } var n = 72 ; findCount ( n ) ;

Accumulator variables: a, b, c, i
Iterator variables: i
Javascript program:
function factorial ( n ) { return ( n == 1 n == 0 ) ? 1 : factorial ( n - 1 ) * n ; } function gcdOfFactorial ( arr , n ) { var minm = arr [ 0 ] ; for ( i = 1 ; i < n ; i ++ ) minm = minm > arr [ i ] ? arr [ i ] : minm ; return factorial ( minm ) ; } var arr = [ 9 , 12 , 122 , 34 , 15 ] ; var n = arr . length ; document . write ( gcdOfFactorial ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findNumbers ( n ) { var i = 1 ; while ( i <= n ) { document . write ( ( ( 2 * i ) - 1 ) + " " ) ; i ++ ; } } var n = 3 ; findNumbers ( n ) ;

Accumulator variables: i
Javascript program:
function findMissingNums ( even , sizeEven , odd , sizeOdd ) { let minEven = Number . MAX_VALUE ; let maxEven = Number . MIN_VALUE ; let minOdd = Number . MAX_VALUE ; let maxOdd = Number . MIN_VALUE ; let sumEvenArr = 0 , sumOddArr = 0 ; for ( let i = 0 ; i < sizeEven ; i ++ ) { minEven = Math . min ( minEven , even [ i ] ) ; maxEven = Math . max ( maxEven , even [ i ] ) ; sumEvenArr += even [ i ] ; } for ( let i = 0 ; i < sizeOdd ; i ++ ) { minOdd = Math . min ( minOdd , odd [ i ] ) ; maxOdd = Math . max ( maxOdd , odd [ i ] ) ; sumOddArr += odd [ i ] ; } let totalTerms = 0 , reqSum = 0 ; totalTerms = parseInt ( minEven / 2 , 10 ) ; let evenSumMin = ( totalTerms * ( totalTerms + 1 ) ) ; totalTerms = parseInt ( maxEven / 2 , 10 ) ; let evenSumMax = ( totalTerms * ( totalTerms + 1 ) ) ; reqSum = evenSumMax - evenSumMin + minEven ; document . write ( " " + ( reqSum - sumEvenArr ) + " " ) ; totalTerms = parseInt ( minOdd / 2 , 10 ) + 1 ; let oddSumMin = totalTerms * totalTerms ; totalTerms = parseInt ( maxOdd / 2 , 10 ) + 1 ; let oddSumMax = totalTerms * totalTerms ; reqSum = oddSumMax - oddSumMin + minOdd ; document . write ( " " + ( reqSum - sumOddArr ) ) ; } let even = [ 6 , 4 , 8 , 14 , 10 ] ; let sizeEven = even . length ; let odd = [ 7 , 5 , 3 , 11 , 13 ] ; let sizeOdd = odd . length ; findMissingNums ( even , sizeEven , odd , sizeOdd ) ;

Index/key variables: i
Accumulator variables: i, sumEvenArr, sumOddArr
Iterator variables: i
Javascript program:
function getResult ( n ) { let proOdd = 1 ; let proEven = 1 ; let num = n . toString ( ) ; for ( let i = 0 ; i < num . length ; i ++ ) if ( i % 2 == 0 ) proOdd = proOdd * ( num [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) ; else proEven = proEven * ( num [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) ; if ( proOdd == proEven ) document . write ( " " ) ; else document . write ( " " ) ; } let n = 4324 ; getResult ( n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function sumOfDigits ( x ) { let sum = 0 ; while ( x != 0 ) { sum += x % 10 ; x = Math . floor ( x / 10 ) ; } return sum ; } function countNumbers ( l , r ) { let count = 0 ; for ( let i = l ; i <= r ; i ++ ) { if ( i % 2 == 0 && sumOfDigits ( i ) % 3 === 0 ) count ++ ; } return count ; } let l = 1000 , r = 6000 ; document . write ( countNumbers ( l , r ) ) ;

Accumulator variables: count, i, sum
Iterator variables: i
Javascript program:
function findMinSum ( arr , n ) { var sum = 0 ; for ( var i = 0 ; i < n ; i ++ ) sum += arr [ i ] * ( n - i ) ; return sum ; } var arr = [ 3 , 5 , 7 , 8 ] ; var n = arr . length ; document . write ( findMinSum ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function maxLenSubArr ( a , n ) { let count , j ; let cm = 1 , max = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( a [ i ] > max ) max = a [ i ] ; } for ( let i = 0 ; i < n - 1 ; ) { count = 1 ; if ( a [ i ] == a [ i + 1 ] && a [ i ] == max ) { for ( j = i + 1 ; j < n ; j ++ ) { if ( a [ j ] == max ) { count ++ ; i ++ ; } else break ; } if ( count > cm ) cm = count ; } else i ++ ; } return cm ; } let arr = [ 6 , 1 , 6 , 6 , 0 ] ; let n = arr . length ; document . write ( maxLenSubArr ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function minSum ( arr , n , x ) { var sum = 0 ; var largestDivisible = - 1 , minimum = arr [ 0 ] ; for ( i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( arr [ i ] % x == 0 && largestDivisible < arr [ i ] ) largestDivisible = arr [ i ] ; if ( arr [ i ] < minimum ) minimum = arr [ i ] ; } if ( largestDivisible == - 1 ) return sum ; var sumAfterOperation = sum - minimum - largestDivisible + ( x * minimum ) + ( largestDivisible / x ) ; return Math . min ( sum , sumAfterOperation ) ; } var arr = [ 5 , 5 , 5 , 5 , 6 ] ; var n = arr . length ; var x = 3 ; document . write ( minSum ( arr , n , x ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function checkSpecialPrime ( sieve , num ) { while ( num > 0 ) { if ( sieve [ num ] ) { return false ; } num = parseInt ( num / 10 ) ; } return true ; } function findSpecialPrime ( N ) { var sieve = Array . from ( { length : N * 10 + 1 } , ( _ , i ) => false ) ; sieve [ 0 ] = true ; sieve [ 1 ] = true ; var i = 0 , j = 0 ; for ( i = 2 ; i <= N * 10 ; i ++ ) { if ( ! sieve [ i ] ) { for ( j = i * i ; j <= N * 10 ; j += i ) { sieve [ j ] = true ; } } } while ( true ) { if ( checkSpecialPrime ( sieve , N ) ) { document . write ( N + " " ) ; break ; } else N ++ ; } } var N = 379 ; findSpecialPrime ( N ) ; N = 100 ; findSpecialPrime ( N ) ;

Index/key variables: i, j, num
Accumulator variables: N, i, j
Iterator variables: i, j
Javascript program:
function minMoves ( n ) { let s = n . toString ( ) ; let ans = Number . MAX_VALUE ; let len = s . length ; for ( let i = 0 ; i < len ; ++ i ) { for ( let j = 0 ; j < len ; ++ j ) { if ( i == j ) continue ; let t = s . split ( ' ' ) ; let cur = 0 ; for ( let k = i ; k < len - 1 ; ++ k ) { swap ( t , k , k + 1 ) ; ++ cur ; } for ( let k = j - ( ( j > i ) ? 1 : 0 ) ; k < len - 2 ; ++ k ) { swap ( t , k , k + 1 ) ; ++ cur ; } let pos = - 1 ; for ( let k = 0 ; k < len ; ++ k ) { if ( t [ k ] != ' ' ) { pos = k ; break ; } } for ( let k = pos ; k > 0 ; -- k ) { swap ( t , k , k - 1 ) ; ++ cur ; } let nn = parseInt ( t . join ( " " ) ) ; if ( nn % 25 == 0 ) ans = Math . min ( ans , cur ) ; } } if ( ans == Number . MAX_VALUE ) return - 1 ; return ans ; } function swap ( t , i , j ) { let temp = t [ i ] ; t [ i ] = t [ j ] ; t [ j ] = temp ; } let n = 509201 ; document . write ( minMoves ( n ) ) ;

Index/key variables: i, j, k
Iterator variables: i, j, k
Javascript program:
let N = 1000005 ; let primeFactors = new Array ( N ) ; primeFactors . fill ( 0 ) ; function findPrimeFactors ( ) { for ( let i = 2 ; i < N ; i ++ ) if ( primeFactors [ i ] == 0 ) for ( let j = i ; j < N ; j += i ) primeFactors [ j ] = primeFactors [ parseInt ( j / i , 10 ) ] + 1 ; for ( let i = 1 ; i < N ; i ++ ) primeFactors [ i ] += primeFactors [ i - 1 ] ; } findPrimeFactors ( ) ; let a = 6 , b = 3 ; document . write ( primeFactors [ a ] - primeFactors [ b ] ) ;

Index/key variables: a, b, i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function digitSum ( n ) { var ans = 0 ; while ( n ) { ans += n % 10 ; n = parseInt ( n / 10 ) ; } return ans ; } function findInt ( n , m ) { var minDigit = Math . floor ( m / 9 ) ; var start = Math . pow ( 10 , minDigit ) - Math . pow ( 10 , minDigit ) % n ; while ( start < 1000000000 ) { if ( digitSum ( start ) == m ) return start ; else start += n ; } return - 1 ; } var n = 13 , m = 32 ; document . write ( findInt ( n , m ) ) ;

Accumulator variables: ans, start
Javascript program:
function smallestDivisor ( n ) { var mx = Math . sqrt ( n ) ; for ( i = 2 ; i <= mx ; i ++ ) if ( n % i == 0 ) return i ; return n ; } function maxSum ( n ) { var res = n ; while ( n > 1 ) { var divi = smallestDivisor ( n ) ; n /= divi ; res += n ; } return res ; } var n = 34 ; document . write ( maxSum ( n ) ) ;

Accumulator variables: i, n, res
Iterator variables: i
Javascript program:
function isPossible ( n , k , arr ) { let sum = arr [ 0 ] ; let maxVal = arr [ 0 ] ; for ( let i = 1 ; i < n ; i ++ ) { sum += arr [ i ] ; maxVal = Math . max ( maxVal , arr [ i ] ) ; } if ( maxVal > ( sum + k ) / n ) return false ; return true ; } let k = 8 ; let arr = [ 1 , 2 , 3 , 4 ] ; let n = arr . length ; if ( isPossible ( n , k , arr ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function maxResult ( n , a , b , c ) { let maxVal = 0 ; for ( let i = 0 ; i <= n ; i += a ) for ( let j = 0 ; j <= n - i ; j += b ) { let z = ( n - ( i + j ) ) / c ; if ( Math . floor ( z ) == Math . ceil ( z ) ) { let x = i / a ; let y = j / b ; maxVal = Math . max ( maxVal , x + y + z ) ; } } return maxVal ; } let n = 10 , a = 5 , b = 3 , c = 4 ; document . write ( maxResult ( n , a , b , c ) ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function EqualNumbers ( a , n ) { for ( let i = 0 ; i < n ; i ++ ) { while ( a [ i ] % 2 == 0 ) { a [ i ] = parseInt ( a [ i ] / 2 , 10 ) ; } while ( a [ i ] % 3 == 0 ) { a [ i ] = parseInt ( a [ i ] / 3 , 10 ) ; } if ( a [ i ] != a [ 0 ] ) { return false ; } } return true ; } let a = [ 50 , 75 , 150 ] ; let n = a . length ; if ( EqualNumbers ( a , n ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function max_gcd ( n , p ) { let count = 0 ; let gcd = 1 ; while ( p % 2 == 0 ) { p >>= 1 ; count ++ ; } if ( count > 0 ) gcd *= Math . pow ( 2 , parseInt ( count / n , 10 ) ) ; for ( let i = 3 ; i <= parseInt ( Math . sqrt ( p ) , 10 ) ; i += 2 ) { count = 0 ; while ( p % i == 0 ) { count ++ ; p = parseInt ( p / i , 10 ) ; } if ( count > 0 ) { gcd *= Math . pow ( i , parseInt ( count / n , 10 ) ) ; } } if ( p > 2 ) gcd *= Math . pow ( p , parseInt ( 1 / n , 10 ) ) ; return gcd ; } let n = 3 ; let p = 80 ; document . write ( max_gcd ( n , p ) ) ;

Accumulator variables: count, gcd, i
Iterator variables: i
Javascript program:
function checkSub ( sub , s ) { let j = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) if ( sub [ j ] == s [ i ] ) j ++ ; return j == sub . length ; } function getMultiple ( s ) { for ( let i = 0 ; i < 1e3 ; i += 8 ) { if ( checkSub ( i . toString ( ) , s ) ) return i ; } return - 1 ; } let s = " " ; document . write ( getMultiple ( s ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Javascript program:
function getResult ( n ) { let st = n . toString ( ) ; for ( let i = 0 ; i < st . length ; i ++ ) { let d = st [ i ] . charCodeAt ( 0 ) - 48 ; if ( n % d == 0 ) { return " " ; } } return " " ; } let n = 9876543 ; document . write ( getResult ( n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i