dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function seriesSum ( n ) { let i = 1 ; let res = 0.0 ; let sign = true ; while ( n > 0 ) { n -- ; if ( sign ) { sign = ! sign ; res = res + ++ i / ++ i ; } else { sign = ! sign ; res = res - ++ i / ++ i ; } } return res ; } let n = 5 ; document . write ( seriesSum ( n ) . toFixed ( 6 ) ) ;

Accumulator variables: n
Boolean variables: sign
Javascript program:
function Mean ( arr , n ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) sum = sum + arr [ i ] ; return sum / n ; } function meanAbsDevtion ( arr , n ) { let absSum = 0 ; for ( let i = 0 ; i < n ; i ++ ) absSum = absSum + Math . abs ( arr [ i ] - Mean ( arr , n ) ) ; return absSum / n ; } let arr = [ 10 , 15 , 15 , 17 , 18 , 21 ] ; let n = arr . length ; document . write ( meanAbsDevtion ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isRatioPossible ( lowCost , upCost , lowQuant , upQuant , r ) { for ( let i = lowQuant ; i <= upQuant ; i ++ ) { let ans = i * r ; if ( lowCost <= ans && ans <= upCost ) return true ; } return false ; } let lowCost = 14 , upCost = 30 , lowQuant = 5 , upQuant = 12 , r = 9 ; if ( isRatioPossible ( lowCost , upCost , lowQuant , upQuant , r ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function findNumbers ( n , d ) { for ( let i = 0 ; i < n - 2 ; i ++ ) document . write ( " " + " " ) ; document . write ( " " + " " ) ; document . write ( n + d ) ; } let N = 3 , D = 5 ; findNumbers ( N , D ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let LET_MAX = 2147483647 ; function checkTrimorphic ( num ) { let cube = num * num * num ; while ( num > 0 ) { if ( num % 10 != cube % 10 ) return false ; num = Math . floor ( num / 10 ) ; cube = Math . floor ( cube / 10 ) ; } return true ; } function nthTrimorphic ( n ) { let count = 0 ; for ( let i = 0 ; i < LET_MAX ; i ++ ) { if ( checkTrimorphic ( i ) ) count ++ ; if ( count == n ) return i ; } return - 1 ; } let n = 9 ; document . write ( nthTrimorphic ( n ) ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function reachTarget ( target ) { target = Math . abs ( target ) ; let sum = 0 , step = 0 ; while ( sum < target || ( sum - target ) % 2 != 0 ) { step ++ ; sum += step ; } return step ; } let target = 5 ; document . write ( reachTarget ( target ) ) ;

Accumulator variables: step, sum
Javascript program:
function unitDigitXRaisedY ( x , y ) { let res = 1 ; for ( let i = 0 ; i < y ; i ++ ) res = ( res * x ) % 10 ; return res ; } document . write ( unitDigitXRaisedY ( 4 , 2 ) ) ;

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

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function sumofFactors ( n ) { if ( n % 2 != 0 ) return 0 ; let res = 1 ; for ( let i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { let count = 0 , curr_sum = 1 ; let curr_term = 1 ; while ( n % i == 0 ) { count ++ ; n = n / i ; if ( i == 2 && count == 1 ) curr_sum = 0 ; curr_term *= i ; curr_sum += curr_term ; } res *= curr_sum ; } if ( n >= 2 ) res *= ( 1 + n ) ; return res ; } let n = 18 ; document . write ( sumofFactors ( n ) ) ;

Accumulator variables: count, curr_sum, curr_term, i, res
Iterator variables: i
Javascript program:
class pair { constructor ( first , second ) { this . first = first ; this . second = second ; } } function LCM ( a , b ) { return Math . floor ( ( a * b ) / ( __gcd ( a , b ) ) ) ; } function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } function lcmOfNumerator ( vect ) { let lcm = vect [ 0 ] . first ; for ( let i = 1 ; i < vect . length ; i ++ ) lcm = LCM ( vect [ i ] . first , lcm ) ; return lcm ; } function gcdOfDemoninators ( vect ) { let gcd = vect [ 0 ] . second ; for ( let i = 1 ; i < vect . length ; i ++ ) gcd = __gcd ( vect [ i ] . second , gcd ) ; return gcd ; } function lcmOfRationals ( vect ) { document . write ( lcmOfNumerator ( vect ) + " " + gcdOfDemoninators ( vect ) ) ; } let vect = [ ] ; vect . push ( new pair ( 2 , 7 ) ) ; vect . push ( new pair ( 3 , 14 ) ) ; vect . push ( new pair ( 5 , 3 ) ) ; lcmOfRationals ( vect ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: pair
Javascript program:
function sumofoddFactors ( n ) { let res = 1 ; while ( n % 2 == 0 ) n = n / 2 ; for ( let i = 3 ; i <= Math . sqrt ( n ) ; i ++ ) { let count = 0 ; let curr_sum = 1 ; let curr_term = 1 ; while ( n % i == 0 ) { count ++ ; n = n / i ; curr_term *= i ; curr_sum += curr_term ; } res *= curr_sum ; } if ( n >= 2 ) res *= ( 1 + n ) ; return res ; } let n = 30 ; document . write ( sumofoddFactors ( n ) ) ;

Accumulator variables: count, curr_sum, curr_term, i, res
Iterator variables: i
Javascript program:
function countSolutions ( n , val ) { let total = 0 ; if ( n == 1 && val >= 0 ) return 1 ; for ( let i = 0 ; i <= val ; i ++ ) { total += countSolutions ( n - 1 , val - i ) ; } return total ; } let n = 5 ; let val = 20 ; document . write ( countSolutions ( n , val ) ) ;

Accumulator variables: i, total
Iterator variables: i
Javascript program:
var N = 6 ; function fib ( f , n ) { var i ; f [ 0 ] = 0 ; f [ 1 ] = 1 ; for ( i = 2 ; i <= n ; i ++ ) f [ i ] = f [ i - 1 ] + f [ i - 2 ] ; } function fibcoef ( fc , f , n ) { for ( i = 0 ; i <= n ; i ++ ) fc [ i ] [ 0 ] = 1 ; for ( i = 1 ; i <= n ; i ++ ) { for ( j = 1 ; j <= i ; j ++ ) { var k = j ; while ( k > 0 ) { k -- ; fc [ i ] [ j ] *= f [ k ] ; } k = 1 ; while ( ( j + 1 ) != k ) fc [ i ] [ j ] /= f [ k ++ ] ; } } } function printFibonomialTriangle ( n ) { var f = Array ( N + 1 ) . fill ( 0 ) ; fib ( f , n ) ; var dp = Array ( N + 1 ) ; for ( var i = 0 ; i < N + 1 ; i ++ ) dp [ i ] = Array ( N + 1 ) . fill ( 0 ) ; for ( i = 0 ; i <= n ; i ++ ) dp [ i ] [ 0 ] = dp [ i ] [ i ] = 1 ; for ( i = 1 ; i <= n ; i ++ ) { for ( j = 1 ; j < i ; j ++ ) dp [ i ] [ j ] = f [ i - j + 1 ] * dp [ i - 1 ] [ j - 1 ] + f [ j - 1 ] * dp [ i - 1 ] [ j ] ; } for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= i ; j ++ ) document . write ( dp [ i ] [ j ] + " " ) ; document . write ( " " ) ; } } var n = 6 ; printFibonomialTriangle ( n ) ;

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j
Javascript program:
function sumofNterm ( a , d , b , r , n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) sum += ( ( a + ( i - 1 ) * d ) * ( b * Math . pow ( r , i - 1 ) ) ) ; return sum ; } let a = 1 ; let d = 1 ; let b = 2 ; let r = 2 ; let n = 3 ; document . write ( sumofNterm ( a , d , b , r , n ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function sumOfTheSeries ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) { let k = 2 ; for ( let j = 1 ; j <= i ; j ++ ) { sum += k ; k += 2 ; } } return sum ; } let n = 5 ; document . write ( " " + sumOfTheSeries ( n ) ) ;

Accumulator variables: i, j, k, sum
Iterator variables: i, j
Javascript program:
function sumOfSeries ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) sum = sum + i * ( i + 1 ) * ( i + 2 ) ; return sum ; } let n = 10 ; document . write ( sumOfSeries ( n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function Series ( x , n ) { let sum = 1 , term = 1 , fct , j , y = 2 , m ; let i ; for ( i = 1 ; i < n ; i ++ ) { fct = 1 ; for ( j = 1 ; j <= y ; j ++ ) { fct = fct * j ; } term = term * ( - 1 ) ; m = term * Math . pow ( x , y ) / fct ; sum = sum + m ; y += 2 ; } return sum ; } let x = 9 ; let n = 10 ; document . write ( Series ( x , n ) . toFixed ( 4 ) ) ;

Accumulator variables: i, j, y
Iterator variables: i, j
Javascript program:
function Series ( x , n ) { var sum = 1 , term = 1 , fct = 1 ; var p = 1 , multi = 1 ; for ( let i = 1 ; i < n ; i ++ ) { fct = fct * multi * ( multi + 1 ) ; p = p * x * x ; term = ( - 1 ) * term ; multi += 2 ; sum = sum + ( term * p ) / fct ; } return sum ; } var x = 9 ; var n = 10 ; document . write ( Series ( x , n ) . toFixed ( 4 ) ) ;

Accumulator variables: i, multi
Iterator variables: i
Javascript program:
function two_factor ( n ) { let twocount = 0 ; while ( n % 2 == 0 ) { twocount ++ ; n = n / 2 ; } return twocount ; } function five_factor ( n ) { let fivecount = 0 ; while ( n % 5 == 0 ) { fivecount ++ ; n = n / 5 ; } return fivecount ; } function find_con_zero ( arr , n ) { let twocount = 0 ; let fivecount = 0 ; for ( let i = 0 ; i < n ; i ++ ) { twocount += two_factor ( arr [ i ] ) ; fivecount += five_factor ( arr [ i ] ) ; } if ( twocount < fivecount ) return twocount ; else return fivecount ; } let arr = [ 100 , 10 , 5 , 25 , 35 , 14 ] ; let n = 6 ; document . write ( find_con_zero ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: fivecount, i, twocount
Iterator variables: i
Javascript program:
function first ( a , b , c ) { a %= b ; for ( let i = 1 ; i <= b ; i ++ ) { a = a * 10 ; if ( a / b == c ) return i ; a %= b ; } return - 1 ; } let a = 1 , b = 4 , c = 5 ; document . write ( first ( a , b , c ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function sumOfTheSeries ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) { let k = 1 ; for ( let j = 1 ; j <= i ; j ++ ) { sum += k ; k += 2 ; } } return sum ; } let n = 5 ; document . write ( " " + sumOfTheSeries ( n ) ) ;

Accumulator variables: i, j, k, sum
Iterator variables: i, j
Javascript program:
function checksum ( n ) { if ( n == 0 ) { document . write ( " " ) ; return ; } var inc ; if ( n > 0 ) inc = 1 ; else inc = - 1 ; for ( i = 0 ; i <= n - 2 ; i += inc ) { if ( i + i + 1 + i + 2 == n ) { document . write ( i + " " + ( i + 1 ) + " " + ( i + 2 ) ) ; return ; } } document . write ( " " ) ; } var n = 6 ; checksum ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function divisorSum ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; ++ i ) { for ( let j = 1 ; j * j <= i ; ++ j ) { if ( i % j == 0 ) { if ( i / j == j ) sum += j ; else sum += j + i / j ; } } } return sum ; } let n = 4 ; document . write ( divisorSum ( n ) + " " ) ; n = 5 ; document . write ( divisorSum ( n ) + " " ) ;

Accumulator variables: sum
Iterator variables: i, j
Javascript program:
function printbinomial ( max ) { for ( let m = 0 ; m <= max ; m ++ ) { document . write ( m ) ; let binom = 1 ; for ( let x = 0 ; x <= m ; x ++ ) { if ( m != 0 && x != 0 ) binom = binom * ( m - x + 1 ) / x ; document . write ( " " + binom + " " ) ; } document . write ( " " ) ; } } let max = 10 ; printbinomial ( max ) ;

Accumulator variables: m, x
Iterator variables: m, x
Javascript program:
function countSetBits ( n ) { var count = 0 ; while ( n ) { n &= ( n - 1 ) ; count ++ ; } return count ; } function countUnsetBitsInGivenRange ( n , l , r ) { var num = ( ( 1 << r ) - 1 ) ^ ( ( 1 << ( l - 1 ) ) - 1 ) ; return ( r - l + 1 ) - countSetBits ( n & num ) ; } var n = 80 ; var l = 1 , r = 4 ; document . write ( countUnsetBitsInGivenRange ( n , l , r ) ) ;

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

Accumulator variables: i
Iterator variables: i
Javascript program:
var MAX = 501 ; function balancedprime ( n ) { var prime = Array ( MAX + 1 ) . fill ( true ) ; for ( var p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( var i = p * 2 ; i <= MAX ; i += p ) prime [ i ] = false ; } } var v = [ ] ; for ( var p = 3 ; p <= MAX ; p += 2 ) if ( prime [ p ] ) v . push ( p ) ; var count = 0 ; for ( var i = 1 ; i < v . length ; i ++ ) { if ( v [ i ] == ( v [ i + 1 ] + v [ i - 1 ] ) / 2 ) count ++ ; if ( count == n ) return v [ i ] ; } } var n = 4 ; document . write ( balancedprime ( n ) ) ;

Index/key variables: i, p
Accumulator variables: count, i, p
Iterator variables: i, p
Javascript program:
var MAX = 1000001 ; var factor = Array ( MAX ) . fill ( 0 ) ; function generatePrimeFactors ( ) { factor [ 1 ] = 1 ; for ( i = 2 ; i < MAX ; i ++ ) factor [ i ] = i ; for ( i = 4 ; i < MAX ; i += 2 ) factor [ i ] = 2 ; for ( i = 3 ; i * i < MAX ; i ++ ) { if ( factor [ i ] == i ) { for ( j = i * i ; j < MAX ; j += i ) { if ( factor [ j ] == j ) factor [ j ] = i ; } } } } function calculateNoOFactors ( n ) { if ( n == 1 ) return 1 ; var ans = 1 ; var dup = factor [ n ] ; var c = 1 ; var j = n / factor [ n ] ; while ( j != 1 ) { if ( factor [ j ] == dup ) c += 1 ; else { dup = factor [ j ] ; ans = ans * ( c + 1 ) ; c = 1 ; } j = j / factor [ j ] ; } ans = ans * ( c + 1 ) ; return ans ; } function smallest ( n ) { for ( i = 1 ; ; i ++ ) if ( calculateNoOFactors ( i ) >= n ) return i ; } generatePrimeFactors ( ) ; var n = 4 ; document . write ( smallest ( n ) ) ;

Index/key variables: i, j, n
Accumulator variables: c, i, j
Iterator variables: i, j
Javascript program:
function squaresum ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) sum += ( i * i ) ; return sum ; } let n = 4 ; document . write ( squaresum ( n ) + " " ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function isPrime ( n ) { let i = 2 ; while ( i * i <= n ) { if ( n % i == 0 ) return false ; i ++ ; } return true ; } function minimumSum ( n ) { if ( isPrime ( n ) ) return 1 ; if ( n % 2 == 0 ) return 2 ; if ( isPrime ( n - 2 ) ) return 2 ; return 3 ; } let n = 27 ; document . write ( minimumSum ( n ) ) ;

Accumulator variables: i
Javascript program:
function firstDigit ( n ) { while ( n >= 10 ) n /= 10 ; return Math . floor ( n ) ; } function lastDigit ( n ) { return Math . floor ( n % 10 ) ; } let n = 98562 ; document . write ( firstDigit ( n ) + " " + lastDigit ( n ) ) ;

Accumulator variables: n
Javascript program:
function isPrime ( x ) { if ( x == 0 x == 1 ) return false ; for ( let i = 2 ; i * i <= x ; ++ i ) if ( x % i == 0 ) return false ; return true ; } function findPrimes ( n ) { document . write ( n ) ; document . write ( 2 + " " + ( n - 2 ) ) ; { document . write ( 3 + " " ) ; n = n - 3 ; for ( let i = 0 ; i < n ; i ++ ) { if ( isPrime ( i ) && isPrime ( n - i ) ) { document . write ( i + " " + ( n - i ) ) ; break ; } } } } let n = 27 ; findPrimes ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let c = [ ] ; function coef ( n ) { c [ 0 ] = 1 ; for ( let i = 0 ; i < n ; c [ 0 ] = - c [ 0 ] , i ++ ) { c [ 1 + i ] = 1 ; for ( let j = i ; j > 0 ; j -- ) c [ j ] = c [ j - 1 ] - c [ j ] ; } } function isPrime ( n ) { coef ( n ) ; c [ 0 ] ++ ; c [ n ] -- ; let i = n ; while ( ( i -- ) > 0 && c [ i ] % n == 0 ) ; return i < 0 ; } let n = 37 ; if ( isPrime ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function countDigit ( n ) { if ( n == 0 ) return 0 ; return ( 1 + countDigit ( n / 10 ) ) ; } function check ( n ) { let l = countDigit ( n ) ; let dup = n ; let sum = 0 ; while ( dup ) { sum += Math . pow ( dup % 10 , l ) ; dup = parseINT ( dup / 10 ) ; } return ( n == sum ) ; } let n = 1634 ; if ( check ( ! n ) ) document . write ( " " ) ; else document . write ( " " ) ;

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

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
let MAX = 100 ; function leyland ( n ) { let ans = [ ] ; let index = 0 ; for ( let x = 2 ; x <= n ; x ++ ) { for ( let y = 2 ; y <= x ; y ++ ) { let temp = Math . pow ( x , y ) + Math . pow ( y , x ) ; ans [ index ] = temp ; index ++ ; } } console . log ( ans ) ans = ans . sort ( ( a , b ) => a - b ) ; console . log ( ans ) for ( let i = 0 ; i < n ; i ++ ) document . write ( ans [ i ] + " " ) ; } let n = 6 ; leyland ( n ) ;

Index/key variables: i, index
Accumulator variables: i, index, x, y
Iterator variables: i, x, y
Javascript program:
function kthgroupsum ( k ) { let cur = ( k * ( k - 1 ) ) + 1 ; let sum = 0 ; while ( k -- ) { sum += cur ; cur += 2 ; } return sum ; } let k = 3 ; document . write ( kthgroupsum ( k ) ) ;

Accumulator variables: cur, k, sum
Javascript program:
function find_factorial ( num1 , num2 ) { let vec = [ ] ; let t = 0 ; let fac = 1 ; let temp = num1 ; while ( 1 ) { if ( temp == 1 ) break ; fac *= temp ; temp -- ; } vec [ t ++ ] = fac ; num1 ++ ; while ( num1 <= num2 ) { fac *= num1 ; vec [ t ++ ] = fac ; num1 ++ ; } return ( vec ) ; } function print_format ( result ) { let x = result . length ; let digits = String ( result [ x - 1 ] ) . length ; for ( let i = 0 ; i < x ; i ++ ) { result [ i ] = new Array ( x - i ) . fill ( " " ) . join ( " " ) + result [ i ] ; document . write ( String ( result [ i ] ) + " " ) ; } } let m = 10 ; let n = 20 ; let result_fac ; result_fac = find_factorial ( m , n ) ; print_format ( result_fac ) ;

Index/key variables: i
Accumulator variables: fac, i, num1, t, temp
Iterator variables: i
Javascript program:
function term ( n ) { let ans = 0 ; for ( let i = 1 ; i <= n ; i ++ ) ans += i ; return ans ; } let n = 4 ; document . write ( term ( n ) ) ;

Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function sum ( x , n ) { let total = 1.0 ; let multi = x ; for ( let i = 1 ; i <= n ; i ++ ) { total = total + multi / i ; multi = multi * x ; } return total ; } let x = 2 ; let n = 5 ; document . write ( sum ( x , n ) . toFixed ( 2 ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function countDigits ( n ) { let c = 0 ; do { c ++ ; n = Math . floor ( n / 10 ) ; } while ( n != 0 ) ; return c ; } function isDeserium ( x ) { let temp = x ; let p = countDigits ( x ) ; let sum = 0 ; while ( x != 0 ) { let digit = x % 10 ; sum += Math . floor ( Math . pow ( digit , p ) ) ; p -- ; x = Math . floor ( x / 10 ) ; } return ( sum == temp ) ; } let x = 135 ; if ( isDeserium ( x ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: c, p, sum
Javascript program:
function mean ( arr , n ) { var sum = 0 ; for ( var i = 0 ; i < n ; i ++ ) sum = sum + arr [ i ] ; var mean = sum / n ; return mean ; } function sd ( arr , n ) { var sum = 0 ; for ( var i = 0 ; i < n ; i ++ ) sum = sum + ( arr [ i ] - mean ( arr , n ) ) * ( arr [ i ] - mean ( arr , n ) ) ; var sdd = sum / n ; return sdd ; } function combinedVariance ( arr1 , arr2 , n , m ) { var mean1 = mean ( arr1 , n ) ; var mean2 = mean ( arr2 , m ) ; document . write ( " " + mean1 . toFixed ( 4 ) + " " ) ; document . write ( " " + mean2 + " " ) ; var sd1 = sd ( arr1 , n ) ; var sd2 = sd ( arr2 , m ) ; document . write ( " " + sd1 . toFixed ( 3 ) + " " ) ; document . write ( " " + sd2 + " " + " " ) ; var combinedMean = ( n * mean1 + m * mean2 ) / ( n + m ) ; document . write ( " " + combinedMean . toFixed ( 4 ) + " " + " " ) ; var d1_square = ( mean1 - combinedMean ) * ( mean1 - combinedMean ) ; var d2_square = ( mean2 - combinedMean ) * ( mean2 - combinedMean ) ; document . write ( " " + d1_square . toFixed ( 3 ) + " " ) ; document . write ( " " + d2_square . toFixed ( 4 ) + " " ) ; var combinedVar = ( n * ( sd1 + d1_square ) + m * ( sd2 + d2_square ) ) / ( n + m ) ; return combinedVar ; } var arr1 = [ 23 , 45 , 34 , 78 , 12 , 76 , 34 ] var arr2 = [ 65 , 67 , 34 , 23 , 45 ] var n = arr1 . length ; var m = arr2 . length ; document . write ( " " + combinedVariance ( arr1 , arr2 , n , m ) . toFixed ( 3 ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function checkDivisibility ( num ) { let length = num . length ; if ( length == 1 && num [ 0 ] == ' ' ) return true ; if ( length % 3 == 1 ) { num += " " ; length += 2 ; } else if ( length % 3 == 2 ) { num += " " ; length += 1 ; } let sum = 0 ; p = 1 ; for ( let i = length - 1 ; i >= 0 ; i -- ) { group = 0 ; group += num [ i -- ] - ' ' ; group += ( num [ i -- ] - ' ' ) * 10 ; group += ( num [ i ] - ' ' ) * 100 ; sum = sum + group * p ; p *= ( - 1 ) ; } sum = Math . abs ( sum ) ; return ( sum % 13 == 0 ) ; } let number = " " ; if ( checkDivisibility ( number ) ) document . write ( number + " " ) ; else document . write ( number + " " ) ;

Index/key variables: i
Accumulator variables: group, i, num, p
Iterator variables: i
Javascript program:
function modularEquation ( a , b ) { if ( a < b ) { document . write ( " " ) ; return ; } if ( a == b ) { document . write ( " " ) ; return ; } let count = 0 ; let n = a - b ; let y = Math . sqrt ( a - b ) ; for ( let i = 1 ; i <= y ; ++ i ) { if ( n % i == 0 ) { if ( n / i > b ) count ++ ; if ( i > b ) count ++ ; } } if ( y * y == n && y > b ) count -- ; document . write ( count ) ; } let a = 21 ; let b = 5 ; modularEquation ( a , b ) ;

Accumulator variables: count
Iterator variables: i
Javascript program:
function countWays ( num ) { let dp = [ ] ; let MOD = 1E9 + 7 ; dp [ 1 ] = 2 ; for ( let i = 2 ; i <= num ; ++ i ) { dp [ i ] = 0 ; for ( let j = 1 ; j <= 3 ; ++ j ) { if ( i - j == 0 ) dp [ i ] += 1 ; else if ( j == 1 ) dp [ i ] += dp [ i - j ] * 2 ; else if ( i - j > 0 ) dp [ i ] += dp [ i - j ] ; if ( dp [ i ] >= MOD ) dp [ i ] %= MOD ; } } return dp [ num ] ; } let n = 3 ; document . write ( countWays ( n ) ) ;

Index/key variables: i, num
Iterator variables: i, j
Javascript program:
function sumSquare ( n ) { let s = new Map ( ) ; for ( let i = 0 ; i * i <= n ; ++ i ) { s . set ( i * i , 1 ) ; if ( s . has ( n - i * i ) ) { document . write ( Math . sqrt ( n - i * i ) + " " + i + " " ) ; return true ; } } return false ; } let n = 169 ; document . write ( sumSquare ( n ) ? " " : " " ) ;

Iterator variables: i
Javascript program:
function judgeSquareSum ( n ) { for ( i = 2 ; i * i <= n ; i ++ ) { var count = 0 ; if ( n % i == 0 ) { while ( n % i == 0 ) { count ++ ; n = parseInt ( n / i ) ; } if ( i % 4 == 3 && count % 2 != 0 ) return false ; } } return n % 4 != 3 ; } var n = 17 ; if ( judgeSquareSum ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function countDigitOne ( n ) { var countr = 0 ; for ( var i = 1 ; i <= n ; i *= 10 ) { var divider = i * 10 ; countr += parseInt ( n / divider ) * i + Math . min ( Math . max ( n % divider - i + 1 , 0 ) , i ) ; } return countr ; } var n = 13 ; document . write ( countDigitOne ( n ) + " " ) ; n = 113 ; document . write ( countDigitOne ( n ) + " " ) ; n = 205 ; document . write ( countDigitOne ( n ) + " " ) ;

Accumulator variables: countr, i
Iterator variables: i
Javascript program:
function isPrime ( c ) { return ( c == ' ' c == ' ' c == ' ' c == ' ' ) ; } function decrease ( s , i ) { if ( s [ i ] <= ' ' ) { s . splice ( i , 1 ) s [ i ] = ' ' ; } else if ( s [ i ] == ' ' ) s [ i ] = ' ' ; else if ( s [ i ] <= ' ' ) s [ i ] = ' ' ; else if ( s [ i ] <= ' ' ) s [ i ] = ' ' ; else s [ i ] = ' ' ; return s ; } function primeDigits ( s ) { for ( let i = 0 ; i < s . length ; i ++ ) { if ( ! isPrime ( s [ i ] ) ) { while ( i >= 0 && s [ i ] . charCodeAt ( 0 ) <= ' ' . charCodeAt ( 0 ) ) i -- ; if ( i < 0 ) { i = 0 ; s = decrease ( s . split ( " " ) , i ) ; } else s = decrease ( s . split ( " " ) , i ) ; for ( let j = i + 1 ; j < s . length ; j ++ ) s [ j ] = ' ' ; break ; } } return s . join ( " " ) ; } let s = " " ; document . write ( primeDigits ( s ) + " " ) ; s = " " ; document . write ( primeDigits ( s ) + " " ) ; s = " " ; document . write ( primeDigits ( s ) + " " ) ; s = " " ; document . write ( primeDigits ( s ) + " " ) ; s = " " ; document . write ( primeDigits ( s ) + " " ) ;

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