dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function findMaxGCD ( arr , n , k ) { arr . sort ( function ( a , b ) { return a - b ; } ) ; let high = arr [ n - 1 ] ; let divisors = new Array ( high + 1 ) ; for ( let i = 0 ; i < divisors . length ; i ++ ) { divisors [ i ] = 0 ; } for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 1 ; j <= Math . sqrt ( arr [ i ] ) ; j ++ ) { if ( arr [ i ] % j == 0 ) { divisors [ j ] ++ ; if ( j != Math . floor ( arr [ i ] / j ) ) divisors [ Math . floor ( arr [ i ] / j ) ] ++ ; } } } for ( let i = high ; i >= 1 ; i -- ) if ( divisors [ i ] >= k ) return i ; return 0 ; } let arr = [ 1 , 2 , 4 , 8 , 8 , 12 ] ; let k = 3 ; let n = arr . length ; document . write ( findMaxGCD ( arr , n , k ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function mulmod ( a , b , mod ) { a = a % mod ; while ( b > 0 ) { if ( b % 2 == 1 ) res = ( res + a ) % mod ; a = ( a * 2 ) % mod ; b = parseInt ( b / 2 , 10 ) ; } return res % mod ; } function findProduct ( N ) { let product = 1 , fact = 1 ; let MOD = ( 1e9 + 7 ) ; for ( let i = 1 ; i <= N ; i ++ ) { fact = mulmod ( fact , i , MOD ) ; product = mulmod ( product , fact , MOD ) ; if ( product == 0 ) return 0 ; } return product ; } let N = 3 ; document . write ( findProduct ( N ) + " " ) ; N = 5 ; document . write ( findProduct ( N ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function divSum ( n ) { let sum = 1 ; for ( let i = 2 ; i * i <= n ; i ++ ) if ( n % i == 0 ) sum = sum + i + parseInt ( n / i , 10 ) ; return sum ; } function areEquivalent ( num1 , num2 ) { return divSum ( num1 ) == divSum ( num2 ) ; } let num1 = 559 ; let num2 = 703 ; if ( areEquivalent ( num1 , num2 ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function bit ( x ) { let ans = 0 ; while ( x > 0 ) { x = parseInt ( x / 2 , 10 ) ; ans ++ ; } return ans ; } function check ( d , x ) { if ( bit ( parseInt ( x / d , 10 ) ) <= bit ( d ) ) return true ; return false ; } function bs ( n ) { let l = 1 , r = Math . sqrt ( n ) ; while ( l < r ) { let m = parseInt ( ( l + r ) / 2 , 10 ) ; if ( check ( m , n ) ) r = m ; else l = m + 1 ; } if ( ! check ( l , n ) ) return l + 1 ; else return l ; } function countDivisor ( n ) { return n - bs ( n ) + 1 ; } let n = 5 ; document . write ( countDivisor ( n ) ) ;

Accumulator variables: ans
Javascript program:
function block ( x ) { let v = [ ] ; document . write ( " " + x + " " ) ; while ( x > 0 ) { v . push ( x % 2 ) ; x = parseInt ( x / 2 , 10 ) ; } for ( let i = 0 ; i < v . length ; i ++ ) { if ( v [ i ] == 1 ) { document . write ( i ) ; if ( i != v . length - 1 ) document . write ( " " ) ; } } document . write ( " " ) ; } block ( 71307 ) ; block ( 1213 ) ; block ( 29 ) ; block ( 100 ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function printCubeFree ( n ) { var cubFree = Array ( n + 1 ) . fill ( false ) ; for ( i = 0 ; i <= n ; i ++ ) cubFree [ i ] = true ; for ( i = 2 ; i * i * i <= n ; i ++ ) { if ( cubFree [ i ] ) { for ( multiple = 1 ; i * i * i * multiple <= n ; multiple ++ ) { cubFree [ i * i * i * multiple ] = false ; } } } for ( i = 2 ; i <= n ; i ++ ) { if ( cubFree [ i ] == true ) document . write ( i + " " ) ; } } printCubeFree ( 20 ) ;

Index/key variables: i
Accumulator variables: i, multiple
Iterator variables: i, multiple
Javascript program:
function heapify ( arr , n , i ) { var smallest = i ; var l = 2 * i + 1 ; var r = 2 * i + 2 ; if ( l < n && arr [ l ] < arr [ smallest ] ) smallest = l ; if ( r < n && arr [ r ] < arr [ smallest ] ) smallest = r ; if ( smallest != i ) { [ arr [ i ] , arr [ smallest ] ] = [ arr [ smallest ] , arr [ i ] ] heapify ( arr , n , smallest ) ; } } function heapSort ( arr , n ) { for ( var i = parseInt ( n / 2 - 1 ) ; i >= 0 ; i -- ) heapify ( arr , n , i ) ; for ( var i = n - 1 ; i >= 0 ; i -- ) { [ arr [ 0 ] , arr [ i ] ] = [ arr [ i ] , arr [ 0 ] ] heapify ( arr , i , 0 ) ; } } function printArray ( arr , n ) { for ( var i = 0 ; i < n ; ++ i ) document . write ( arr [ i ] + " " ) ; document . write ( " " ) ; } var arr = [ 4 , 6 , 3 , 2 , 9 ] ; var n = arr . length ; heapSort ( arr , n ) ; document . write ( " " ) ; printArray ( arr , n ) ;

Index/key variables: i, l, r, smallest
Accumulator variables: i
Iterator variables: i
Javascript program:
function trickyCase ( s , index ) { let index1 = - 1 ; for ( let i = index - 1 ; i >= 0 ; i -- ) { let digit = s [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; if ( digit != 8 ) { index1 = i ; break ; } } if ( index1 == - 1 ) return 2 * Math . pow ( 10 , s . length ) ; let num = 0 ; for ( let i = 0 ; i < index1 ; i ++ ) num = num * 10 + ( s [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) ; if ( s [ index1 ] . charCodeAt ( ) % 2 == 0 ) num = num * 10 + ( s [ index1 ] . charCodeAt ( ) - ' ' . charCodeAt ( ) + 2 ) ; else num = num * 10 + ( s [ index1 ] . charCodeAt ( ) - ' ' . charCodeAt ( ) + 1 ) ; for ( let i = index1 + 1 ; i < s . length ; i ++ ) num = num * 10 ; return num ; } function smallestNumber ( n ) { let num = 0 ; let s = " " ; let duplicate = n ; while ( n > 0 ) { s = String . fromCharCode ( n % 10 + 48 ) + s ; n = parseInt ( n / 10 , 10 ) ; } let index = - 1 ; for ( let i = 0 ; i < s . length ; i ++ ) { let digit = s [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; let val = digit & 1 ; if ( val == 1 ) { index = i ; break ; } } if ( index == - 1 ) return duplicate ; if ( s [ index ] == ' ' ) { num = trickyCase ( s , index ) ; return num ; } for ( let i = 0 ; i < index ; i ++ ) num = num * 10 + ( s [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) ; num = num * 10 + ( s [ index ] . charCodeAt ( ) - ' ' . charCodeAt ( ) + 1 ) ; for ( let i = index + 1 ; i < s . length ; i ++ ) num = num * 10 ; return num ; } let N = 2397 ; document . write ( smallestNumber ( N ) ) ;

Index/key variables: i, index, index1
Accumulator variables: i
Iterator variables: i
Javascript program:
function findNth ( n ) { let count = 0 ; for ( let curr = 19 ; ; curr += 9 ) { let sum = 0 ; for ( let x = curr ; x > 0 ; x = parseInt ( x / 10 ) ) sum = sum + x % 10 ; if ( sum == 10 ) count ++ ; if ( count == n ) return curr ; } return - 1 ; } document . write ( findNth ( 5 ) ) ;

Accumulator variables: count, curr
Iterator variables: curr, x
Javascript program:
function findSum ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) for ( let j = i ; j <= n ; j ++ ) sum = sum + i * j ; return sum ; } let n = 5 ; document . write ( findSum ( n ) ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function findSum ( n ) { let multiTerms = n * ( n + 1 ) / 2 ; let sum = multiTerms ; for ( let i = 2 ; i <= n ; i ++ ) { multiTerms = multiTerms - ( i - 1 ) ; sum = sum + multiTerms * i ; } return sum ; } let n = 5 ; document . write ( findSum ( n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function isDvisibleBy12 ( num ) { if ( num . length >= 3 ) { let d1 = num [ num . length - 1 ] . charCodeAt ( ) ; if ( d1 % 2 != 0 ) return false ; let d2 = num [ num . length - 2 ] . charCodeAt ( ) ; let sum = 0 ; for ( let i = 0 ; i < num . length ; i ++ ) sum += num [ i ] . charCodeAt ( ) ; return ( ( sum % 3 == 0 ) && ( d2 * 10 + d1 ) % 4 == 0 ) ; } else { let number = parseInt ( num , 10 ) ; document . write ( number ) ; return ( number % 12 == 0 ) ; } } let num = " " ; if ( isDvisibleBy12 ( num ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function check ( n ) { let d = Math . sqrt ( n ) ; if ( d * d == n ) return true ; return false ; } function largestNonPerfectSquareNumber ( a , n ) { let maxi = - 1 ; for ( let i = 0 ; i < n ; i ++ ) { if ( ! check ( a [ i ] ) ) maxi = Math . max ( a [ i ] , maxi ) ; } return maxi ; } let a = [ 16 , 20 , 25 , 2 , 3 , 10 ] ; let n = a . length ; document . write ( largestNonPerfectSquareNumber ( a , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function printAP ( a , d , n ) { let curr_term ; curr_term = a ; for ( let i = 1 ; i <= n ; i ++ ) { document . write ( curr_term + " " ) ; curr_term = curr_term + d ; } } let a = 2 ; let d = 1 ; let n = 5 ; printAP ( a , d , n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function printNonSquare ( n ) { let curr_count = 2 , num = 2 , count = 0 ; while ( count < n ) { for ( let i = 0 ; i < curr_count && count < n ; i ++ ) { document . write ( num + " " ) ; count ++ ; num ++ ; } num ++ ; curr_count += 2 ; } } let n = 10 ; printNonSquare ( n ) ;

Accumulator variables: count, curr_count, i, num
Iterator variables: i
Javascript program:
function countZeros ( a , n ) { let count2 = 0 , count5 = 0 ; for ( let i = 0 ; i < n ; i ++ ) { while ( a [ i ] % 2 == 0 ) { a [ i ] = parseInt ( a [ i ] / 2 ) ; count2 ++ ; } while ( a [ i ] % 5 == 0 ) { a [ i ] = parseInt ( a [ i ] / 5 ) ; count5 ++ ; } } return ( count2 < count5 ) ? count2 : count5 ; } let a = [ 10 , 100 , 20 , 30 , 50 , 90 , 12 , 80 ] ; let n = a . length ; document . write ( countZeros ( a , n ) ) ;

Index/key variables: i
Accumulator variables: count2, count5, i
Iterator variables: i
Javascript program:
function squareSum ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) sum += ( 2 * i ) * ( 2 * i ) ; return sum ; } document . write ( squareSum ( 8 ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
var pwr ; function isMunchhausen ( n ) { var sum = 0 ; var temp = n ; while ( temp > 0 ) { var index = temp % 10 ; sum = sum + pwr [ index ] ; temp = parseInt ( temp / 10 ) ; } return ( sum == n ) ; } function printMunchhausenNumbers ( n ) { pwr = Array . from ( { length : 10 } , ( _ , i ) => 0 ) ; for ( var i = 0 ; i < 10 ; i ++ ) pwr [ i ] = Math . pow ( i , i ) ; for ( var i = 1 ; i <= n ; i ++ ) if ( isMunchhausen ( i ) == true ) document . write ( i + " " ) ; } var n = 10000 ; printMunchhausenNumbers ( n ) ;

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Javascript program:
function kthdigit ( a , b , k ) { let p = Math . pow ( a , b ) ; let count = 0 ; while ( p > 0 && count < k ) { let rem = p % 10 ; count ++ ; if ( count == k ) return rem ; p = p / 10 ; } return 0 ; } let a = 5 , b = 2 ; let k = 1 ; document . write ( kthdigit ( a , b , k ) ) ;

Accumulator variables: count
Javascript program:
function maxArea ( A , len ) { let l = 0 ; let r = len - 1 ; let area = 0 ; while ( l < r ) { area = Math . max ( area , Math . min ( A [ l ] , A [ r ] ) * ( r - l ) ) ; if ( A [ l ] < A [ r ] ) l += 1 ; else r -= 1 ; } return area ; } let a = [ 1 , 5 , 4 , 3 ] ; let b = [ 3 , 1 , 2 , 4 , 5 ] ; let len1 = a . length ; document . write ( maxArea ( a , len1 ) + " " ) ; let len2 = b . length ; document . write ( maxArea ( b , len2 ) ) ;

Index/key variables: l, r
Accumulator variables: l, r
Javascript program:
function mobius ( n ) { let p = 0 ; if ( n % 2 == 0 ) { n = parseInt ( n / 2 , 10 ) ; p ++ ; if ( n % 2 == 0 ) return 0 ; } for ( let i = 3 ; i <= Math . sqrt ( n ) ; i = i + 2 ) { if ( n % i == 0 ) { n = parseInt ( n / i , 10 ) ; p ++ ; if ( n % i == 0 ) return 0 ; } } return ( p % 2 == 0 ) ? - 1 : 1 ; } let N = 17 ; document . write ( " " + " " + N + " " + mobius ( N ) + " " ) ; document . write ( " " + " " + 25 + " " + mobius ( 25 ) + " " ) ; document . write ( " " + " " + 6 + " " + mobius ( 6 ) ) ;

Accumulator variables: p
Iterator variables: i
Javascript program:
function factorial ( start , end ) { let res = 1 ; for ( let i = start ; i <= end ; i ++ ) res *= i ; return res ; } function sumofsquare ( n ) { return parseInt ( factorial ( n + 1 , 2 * n ) / factorial ( 1 , n ) , 10 ) ; } let n = 4 ; document . write ( sumofsquare ( n ) ) ;

Accumulator variables: i, res
Iterator variables: i
Javascript program:
let PHI = 1.6180339 ; let f = [ 0 , 1 , 1 , 2 , 3 , 5 ] ; function fib ( n ) { if ( n < 6 ) return f [ n ] ; let t = 5 , fn = 5 ; while ( t < n ) { fn = Math . round ( fn * PHI ) ; t ++ ; } return fn ; } let n = 9 ; document . write ( n + " " + fib ( n ) + " " ) ;

Index/key variables: n
Accumulator variables: t
Javascript program:
function solution ( a , b , n ) { for ( let i = 0 ; i * a <= n ; i ++ ) { if ( ( n - ( i * a ) ) % b == 0 ) { document . write ( " " + i + " " + ( n - ( i * a ) ) / b ) ; return ; } } document . write ( " " ) ; } let a = 2 , b = 3 , n = 7 ; solution ( a , b , n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function precisionCompute ( x , y , n ) { if ( y == 0 ) { document . write ( " " ) ; return ; } if ( x == 0 ) { document . write ( " " ) ; return ; } if ( n <= 0 ) { document . write ( x / y ) ; return ; } if ( ( ( x > 0 ) && ( y < 0 ) ) || ( ( x < 0 ) && ( y > 0 ) ) ) { document . write ( " " ) ; x = x > 0 ? x : - x ; y = y > 0 ? y : - y ; } let d = x / y ; for ( let i = 0 ; i <= n ; i ++ ) { document . write ( d ) ; x = x - ( y * d ) ; if ( x == 0 ) break ; x = x * 10 ; d = x / y ; if ( i == 0 ) document . write ( " " ) ; } } let x = 22 , y = 7 , n = 15 ; precisionCompute ( x , y , n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function checkDigits ( n ) { while ( n > 0 ) { let dig = n % 10 ; if ( dig != 2 && dig != 3 && dig != 5 && dig != 7 ) return false ; n = parseInt ( n / 10 , 10 ) ; } return true ; } function prime ( n ) { if ( n == 1 ) return false ; for ( let i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } function isFullPrime ( n ) { return ( checkDigits ( n ) && prime ( n ) ) ; } let n = 53 ; if ( isFullPrime ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function getResult ( st ) { let sum = 0 ; let length = st . length ; for ( let i = 0 ; i < length ; i ++ ) { sum = sum + Math . pow ( st [ i ] - ' ' , length ) ; } let number = parseInt ( st , 10 ) ; if ( number == sum ) return " " ; else return " " ; } let st = " " ; document . write ( getResult ( st ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX = 500 ; function nthSHN ( n , dp ) { if ( n == 1 n == 2 ) return dp [ n ] = 1 ; if ( dp [ n ] != - 1 ) return dp [ n ] ; return dp [ n ] = ( ( 6 * n - 9 ) * nthSHN ( n - 1 , dp ) - ( n - 3 ) * nthSHN ( n - 2 , dp ) ) / n ; } let n = 6 ; let dp = new Array ( MAX ) ; for ( let i = 0 ; i < dp . length ; i ++ ) dp [ i ] = - 1 ; document . write ( nthSHN ( n , dp ) ) ;

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Javascript program:
function evenSum ( n ) { let curr = 2 , sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) { sum += curr ; curr += 2 ; } return sum ; } let n = 20 ; document . write ( " " + n + " " + evenSum ( n ) ) ;

Accumulator variables: curr, i, sum
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function findNumber ( arr , n ) { let ans = arr [ 0 ] ; for ( let i = 0 ; i < n ; i ++ ) ans = gcd ( ans , arr [ i ] ) ; for ( let i = 0 ; i < n ; i ++ ) if ( arr [ i ] == ans ) return ans ; return - 1 ; } let arr = [ 2 , 2 , 4 ] ; let n = arr . length ; document . write ( findNumber ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let primes = [ ] ; function SieveofEratosthenes ( n ) { let visited = new Array ( n ) ; visited . fill ( false ) ; for ( let i = 2 ; i <= n + 1 ; i ++ ) if ( ! visited [ i ] ) { for ( let j = i * i ; j <= n + 1 ; j += i ) visited [ j ] = true ; primes . push ( i ) ; } } function specialPrimeNumbers ( n , k ) { SieveofEratosthenes ( n ) ; let count = 0 ; for ( let i = 0 ; i < primes . length ; i ++ ) { for ( let j = 0 ; j < i - 1 ; j ++ ) { if ( primes [ j ] + primes [ j + 1 ] + 1 == primes [ i ] ) { count ++ ; break ; } } if ( count == k ) return true ; } return false ; } let n = 27 , k = 2 ; if ( specialPrimeNumbers ( n , k ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function factorize ( n ) { var count = 0 ; while ( ( n % 2 ) == 0 ) { count ++ ; } if ( count ) document . write ( 2 + " " + count + " " ) ; for ( var i = 3 ; i <= parseInt ( Math . sqrt ( n ) ) ; i += 2 ) { count = 0 ; while ( n % i == 0 ) { count ++ ; n = parseInt ( n / i ) ; } if ( count != 0 ) document . write ( i + " " + count + " " ) ; } if ( n > 2 ) document . write ( n + " " + 1 + " " ) ; } var n = 1000000000000000000 ; factorize ( n ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function __gcd ( a , b ) { if ( a == 0 ) return b ; return __gcd ( b % a , a ) ; } function minimumMoves ( A , N ) { let one = 0 ; for ( let i = 0 ; i < N ; i ++ ) if ( A [ i ] == 1 ) one ++ ; if ( one != 0 ) return N - one ; let minimum = Number . MAX_SAFE_INTEGER ; for ( let i = 0 ; i < N ; i ++ ) { let g = A [ i ] ; for ( let j = i + 1 ; j < N ; j ++ ) { g = __gcd ( A [ j ] , g ) ; if ( g == 1 ) { minimum = Math . min ( minimum , j - i ) ; break ; } } } if ( minimum == Number . MAX_SAFE_INTEGER ) return - 1 ; else return N + minimum - 1 ; } let A = [ 2 , 4 , 3 , 9 ] ; let N = A . length ; document . write ( minimumMoves ( A , N ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, one
Iterator variables: i, j
Javascript program:
function series ( n , d ) { if ( d == 0 ) { for ( let i = 0 ; i < n ; i ++ ) document . write ( " " ) ; document . write ( ) ; return ; } if ( n % 2 == 0 ) { for ( let i = 1 ; i <= n ; i ++ ) { document . write ( Math . pow ( - 1 , i ) * d + " " ) ; } document . write ( ) ; } else { let m = n ; let r = ( m / ( m - 1 ) ) ; let g = ( d * ( Math . sqrt ( r ) ) ) ; document . write ( " " ) ; for ( let i = 1 ; i < n ; i ++ ) { document . write ( Math . pow ( - 1 , i ) * g + " " ) ; } document . write ( ) ; } } let n = 3 , d = 3 ; series ( n , d ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function countDigitOne ( n ) { let countr = 0 ; for ( let i = 1 ; i <= n ; i ++ ) { let str = i . toString ( ) ; countr += str . split ( " " ) . length - 1 ; } return countr ; } let n = 13 ; document . write ( countDigitOne ( n ) + " " ) ; n = 131 ; document . write ( countDigitOne ( n ) + " " ) ; n = 159 ; document . write ( countDigitOne ( n ) + " " ) ;

Accumulator variables: countr, i
Iterator variables: i
Javascript program:
function factorial ( x ) { if ( x <= 1 ) return 1 ; var res = 2 ; for ( i = 3 ; i <= x ; i ++ ) res = res * i ; return res ; } function gcdOfFactorial ( m , n ) { var min = m < n ? m : n ; return factorial ( min ) ; } var m = 5 , n = 9 ; document . write ( gcdOfFactorial ( m , n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function calculate ( a , b , n , m ) { let mul = 1 ; for ( let i = 0 ; i < m ; i ++ ) if ( b [ i ] != 0 ) mul = mul * b [ i ] ; for ( let i = 0 ; i < n ; i ++ ) { let x = Math . floor ( a [ i ] / mul ) ; document . write ( x + " " ) ; } } let a = [ 5 , 100 , 8 ] ; let b = [ 2 , 3 ] ; let n = a . length ; let m = b . length ; calculate ( a , b , n , m ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
class pair { constructor ( first , second ) { this . first = first ; this . second = second ; } } function findPowerOfP ( n , p ) { let count = 0 ; let r = p ; while ( r <= n ) { count += Math . floor ( n / r ) ; r = r * p ; } return count ; } function primeFactorsofK ( k ) { let ans = [ ] ; for ( let i = 2 ; k != 1 ; i ++ ) { if ( k % i == 0 ) { let count = 0 ; while ( k % i == 0 ) { k = Math . floor ( k / i ) ; count ++ ; } ans . push ( new pair ( i , count ) ) ; } } return ans ; } function largestPowerOfK ( n , k ) { let vec = [ ] ; vec = primeFactorsofK ( k ) ; let ans = Number . MAX_VALUE ; for ( let i = 0 ; i < vec . length ; i ++ ) ans = Math . min ( ans , findPowerOfP ( n , vec [ i ] . first ) / vec [ i ] . second ) ; return ans ; } document . write ( largestPowerOfK ( 7 , 2 ) + " " ) ; document . write ( largestPowerOfK ( 10 , 9 ) + " " ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: pair
Javascript program:
function print ( n ) { document . write ( n + parseInt ( n / 2 ) + " " ) ; for ( i = 2 ; i <= n ; i += 2 ) document . write ( i + " " ) ; for ( i = 1 ; i <= n ; i += 2 ) document . write ( i + " " ) ; for ( i = 2 ; i <= n ; i += 2 ) document . write ( i + " " ) ; } var n = 3 ; print ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function u_cal ( u , n ) { var temp = u ; for ( var i = 1 ; i < n ; i ++ ) temp = temp * ( u + i ) ; return temp ; } function fact ( n ) { var f = 1 ; for ( var i = 2 ; i <= n ; i ++ ) f *= i ; return f ; } var n = 5 ; var x = [ 1891 , 1901 , 1911 , 1921 , 1931 ] ; var y = Array ( n ) . fill ( 0.0 ) . map ( x => Array ( n ) . fill ( 0.0 ) ) ; y [ 0 ] [ 0 ] = 46 ; y [ 1 ] [ 0 ] = 66 ; y [ 2 ] [ 0 ] = 81 ; y [ 3 ] [ 0 ] = 93 ; y [ 4 ] [ 0 ] = 101 ; for ( var i = 1 ; i < n ; i ++ ) { for ( var j = n - 1 ; j >= i ; j -- ) y [ j ] [ i ] = y [ j ] [ i - 1 ] - y [ j - 1 ] [ i - 1 ] ; } for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j <= i ; j ++ ) document . write ( y [ i ] [ j ] + " " ) ; document . write ( ' ' ) ; ; } var value = 1925 ; var sum = y [ n - 1 ] [ 0 ] ; var u = ( value - x [ n - 1 ] ) / ( x [ 1 ] - x [ 0 ] ) ; for ( var i = 1 ; i < n ; i ++ ) { sum = sum + ( u_cal ( u , i ) * y [ n - 1 ] [ i ] ) / fact ( i ) ; } document . write ( " " + value + " " + sum ) ;

Index/key variables: i, j
Accumulator variables: f, i, j
Iterator variables: i, j
Javascript program:
function sumDigitSquare ( n ) { let sq = 0 ; while ( n != 0 ) { let digit = n % 10 ; sq += digit * digit ; n = parseInt ( n / 10 , 10 ) ; } return sq ; } function isHappy ( n ) { while ( true ) { if ( n == 1 ) return true ; n = sumDigitSquare ( n ) ; if ( n == 4 ) return false ; } } let n = 23 ; if ( isHappy ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: sq
Javascript program:
function findMin ( a , n ) { var sum = 0 ; for ( i = 0 ; i < n ; i ++ ) sum += Math . log ( a [ i ] ) ; var x = parseInt ( Math . exp ( sum / n ) ) ; return x + 1 ; } var a = [ 3 , 2 , 1 , 4 ] ; var n = a . length ; document . write ( findMin ( a , n ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function countdigits ( N ) { var count = 0 ; while ( N > 0 ) { count ++ ; N = parseInt ( N / 10 ) ; } return count ; } function cyclic ( N ) { var num = N ; var n = countdigits ( N ) ; while ( true ) { document . write ( num + " " ) ; var rem = num % 10 ; var dev = parseInt ( num / 10 ) ; num = parseInt ( ( ( Math . pow ( 10 , n - 1 ) ) * rem + dev ) ) ; if ( num == N ) break ; } } var N = 5674 ; cyclic ( N ) ;

Accumulator variables: count
Javascript program:
function countDigits ( a , b ) { let count = 0 ; let p = Math . abs ( a * b ) ; if ( p == 0 ) return 1 ; while ( p > 0 ) { count ++ ; p = parseInt ( p / 10 , 10 ) ; } return count ; } let a = 33 ; let b = - 24 ; document . write ( " " + countDigits ( a , b ) ) ;

Accumulator variables: count
Javascript program:
function minNum ( arr , n ) { let odd = false ; for ( let i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 != 0 ) odd = ! odd ; if ( odd ) return 1 ; return 2 ; } let arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ; let n = arr . length ; document . write ( minNum ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: odd
Javascript program:
function msbPos ( n ) { var pos = 0 ; while ( n != 0 ) { pos ++ ; n = n >> 1 ; } return pos ; } function josephify ( n ) { var position = msbPos ( n ) ; var j = 1 << ( position - 1 ) ; n = n ^ j ; n = n << 1 ; n = n | 1 ; return n ; } var n = 41 ; document . write ( josephify ( n ) ) ;

Accumulator variables: pos