dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function factors ( n ) { let prime = new Map ( ) ; for ( let i = 2 ; i <= Math . sqrt ( n ) ; ++ i ) { while ( n % i == 0 ) { if ( prime . has ( i ) ) { prime . set ( i , prime . get ( i ) + 1 ) ; } else { prime . set ( i , 1 ) ; } n = Math . floor ( n / i ) ; } } if ( n > 2 ) { if ( prime . has ( n ) ) { prime . set ( n , prime . get ( n ) + 1 ) ; } else { prime . set ( n , 1 ) ; } } let ans1 = 1 , ans2 = 1 ; for ( let [ key , value ] of prime . entries ( ) ) { ans1 *= 2 * value + 1 ; ans2 *= value + 1 ; } return ans1 - ans2 ; } let n = 5 ; document . write ( factors ( n ) + " " ) ; n = 8 ; document . write ( factors ( n ) + " " ) ;

Accumulator variables: ans1, ans2
Iterator variables: i
Javascript program:
function greatest ( s ) { let n = s . length ; let a = new Array ( n ) ; let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { a [ i ] = s [ i ] - ' ' ; sum += a [ i ] ; } if ( a [ n - 1 ] % 2 ) { if ( a [ n - 2 ] % 2 != 0 || ( sum - a [ n - 1 ] ) % 3 != 0 ) { document . write ( " " + " " ) ; } else { document . write ( n + " " ) ; } } else { let re = sum % 3 ; let del = - 1 ; let flag = 0 ; for ( let i = 0 ; i < n - 1 ; i ++ ) { if ( ( a [ i ] ) % 3 === re ) { if ( a [ i + 1 ] > a [ i ] ) { del = i ; flag = 1 ; break ; } else { del = i ; } } } if ( flag === 0 ) { if ( a [ n - 2 ] % 2 === 0 && re === a [ n - 1 ] % 3 ) del = n - 1 ; } if ( del === - 1 ) document . write ( - 1 + " " ) ; else { document . write ( del + 1 + " " ) ; } } } let s = " " ; greatest ( s ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function divisible ( num ) { let n = num . length ; let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) sum += ( num . charAt ( i ) ) ; if ( sum % 3 == 0 ) return 0 ; if ( n == 1 ) return - 1 ; for ( let i = 0 ; i < n ; i ++ ) if ( sum % 3 == ( num . charAt ( i ) - ' ' ) % 3 ) return 1 ; if ( n == 2 ) return - 1 ; return 2 ; } let num = " " ; document . write ( divisible ( num ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
let n = 3 ; function dotProduct ( vect_A , vect_B ) { let product = 0 ; for ( let i = 0 ; i < n ; i ++ ) product = product + vect_A [ i ] * vect_B [ i ] ; return product ; } function crossProduct ( vect_A , vect_B , cross_P ) { cross_P [ 0 ] = vect_A [ 1 ] * vect_B [ 2 ] - vect_A [ 2 ] * vect_B [ 1 ] ; cross_P [ 1 ] = vect_A [ 2 ] * vect_B [ 0 ] - vect_A [ 0 ] * vect_B [ 2 ] ; cross_P [ 2 ] = vect_A [ 0 ] * vect_B [ 1 ] - vect_A [ 1 ] * vect_B [ 0 ] ; } let vect_A = [ 3 , - 5 , 4 ] ; let vect_B = [ 2 , 6 , 5 ] ; let cross_P = [ ] ; document . write ( " " ) ; document . write ( dotProduct ( vect_A , vect_B ) + " " ) ; document . write ( " " ) ; crossProduct ( vect_A , vect_B , cross_P ) ; for ( let i = 0 ; i < n ; i ++ ) document . write ( cross_P [ i ] + " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX = 1000001 ; let factor = [ ] ; function cal_factor ( ) { factor [ 1 ] = 1 ; for ( let i = 2 ; i < MAX ; i ++ ) factor [ i ] = i ; for ( let i = 4 ; i < MAX ; i += 2 ) factor [ i ] = 2 ; for ( let i = 3 ; i * i < MAX ; i ++ ) { if ( factor [ i ] == i ) { for ( let j = i * i ; j < MAX ; j += i ) { if ( factor [ j ] == j ) factor [ j ] = i ; } } } } function no_of_representations ( a , n ) { let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let temp = a [ i ] ; let flag = 0 ; while ( factor [ temp ] != 1 ) { flag = - 1 ; count ++ ; temp = temp / factor [ temp ] ; } count += flag ; } return count ; } cal_factor ( ) ; let a = [ 4 , 4 , 4 ] ; let n = a . length ; document . write ( no_of_representations ( a , n ) ) ;

Index/key variables: i, j, temp
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function coutSubSeq ( A , N , M ) { let sum = 0 ; let ans = 0 ; for ( let i = 0 ; i < N ; i ++ ) { for ( let j = i + 1 ; j < N ; j ++ ) { for ( let k = j + 1 ; k < N ; k ++ ) { sum = A [ i ] + A [ j ] + A [ k ] ; if ( sum % M == 0 ) ans ++ ; } } } return ans ; } let M = 3 ; let A = [ 1 , 2 , 4 , 3 ] ; let N = A . length ; document . write ( coutSubSeq ( A , N , M ) ) ;

Index/key variables: i, j, k
Accumulator variables: ans, i, j, k
Iterator variables: i, j, k
Javascript program:
function countSubSeq ( A , N , M ) { var ans = 0 ; var h = Array . from ( { length : M } , ( _ , i ) => 0 ) ; for ( var i = 0 ; i < N ; i ++ ) { A [ i ] = A [ i ] % M ; h [ A [ i ] ] ++ ; } for ( var i = 0 ; i < M ; i ++ ) { for ( var j = i ; j < M ; j ++ ) { var rem = ( M - ( i + j ) % M ) % M ; if ( rem < j ) continue ; if ( i == j && rem == j ) ans += h [ i ] * ( h [ i ] - 1 ) * ( h [ i ] - 2 ) / 6 ; else if ( i == j ) ans += h [ i ] * ( h [ i ] - 1 ) * h [ rem ] / 2 ; else if ( i == rem ) ans += h [ i ] * ( h [ i ] - 1 ) * h [ j ] / 2 ; else if ( rem == j ) ans += h [ j ] * ( h [ j ] - 1 ) * h [ i ] / 2 ; else ans = ans + h [ i ] * h [ j ] * h [ rem ] ; } } return ans ; } var M = 3 ; var A = [ 1 , 2 , 4 , 3 ] ; var N = A . length ; document . write ( countSubSeq ( A , N , M ) ) ;

Index/key variables: i, j, rem
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
function findTerm ( n ) { if ( n == 1 ) return n ; else { let term = 7 ; for ( let i = 2 ; i <= n ; i ++ ) term = term * 2 + ( i - 1 ) ; return term ; } } let n = 5 ; document . write ( findTerm ( n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function findNumber ( n ) { n -- ; let i = 1 ; while ( n >= 0 ) { n -= i ; ++ i ; } return ( n + i ) ; } let n = 3 ; document . write ( findNumber ( n ) ) ;

Accumulator variables: n
Javascript program:
function weightedMean ( X , W , n ) { let sum = 0 , numWeight = 0 ; for ( let i = 0 ; i < n ; i ++ ) { numWeight = numWeight + X [ i ] * W [ i ] ; sum = sum + W [ i ] ; } return ( numWeight ) / sum ; } let X = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ; let W = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ; let n = X . length ; let m = W . length ; if ( n == m ) document . write ( weightedMean ( X , W , n ) ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function harmonicMean ( arr , n ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) sum = sum + ( 1 / arr [ i ] ) ; return n / sum ; } let arr = [ 13.5 , 14.5 , 14.8 , 15.2 , 16.1 ] ; let n = arr . length ; document . write ( harmonicMean ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function harmonicMean ( arr , freq , n ) { let sum = 0 , frequency_sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { sum = sum + ( freq [ i ] / arr [ i ] ) ; frequency_sum = frequency_sum + freq [ i ] ; } return frequency_sum / sum ; } let num = [ 13 , 14 , 15 , 16 , 17 ] ; let freq = [ 2 , 5 , 13 , 7 , 3 ] ; let n = num . length ; document . write ( harmonicMean ( num , freq , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function point ( a , b , c , d , n ) { let x ; let flag = 0 ; for ( let i = 0 ; i < n ; i ++ ) { x = b + i * a ; if ( ( x - d ) % c == 0 && x - d >= 0 ) { document . write ( x ) ; flag = 1 ; break ; } } if ( flag == 0 ) { document . write ( " " ) ; } } let a = 20 ; let b = 2 ; let c = 9 ; let d = 19 ; let n = 20 ; point ( a , b , c , d , n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function findArmstrong ( low , high ) { for ( let i = low + 1 ; i < high ; ++ i ) { let x = i ; let n = 0 ; while ( x != 0 ) { x = parseInt ( x / 10 ) ; ++ n ; } let pow_sum = 0 ; x = i ; while ( x != 0 ) { let digit = x % 10 ; pow_sum += parseInt ( Math . pow ( digit , n ) ) ; x = parseInt ( x / 10 ) ; } if ( pow_sum == i ) document . write ( i + " " ) ; } } let num1 = 100 ; let num2 = 400 ; findArmstrong ( num1 , num2 ) ;

Accumulator variables: pow_sum
Iterator variables: i
Javascript program:
function gcdMax ( a , b , n , N ) { let cnt = Array . from ( { length : N } , ( _ , i ) => 0 ) ; let first = Array . from ( { length : N } , ( _ , i ) => 0 ) ; let second = Array . from ( { length : N } , ( _ , i ) => 0 ) ; for ( let i = 0 ; i < n ; ++ i ) cnt [ a [ i ] ] = 1 ; for ( let i = 1 ; i < N ; ++ i ) for ( let j = i ; j < N ; j += i ) if ( cnt [ j ] > 0 ) first [ i ] = Math . max ( first [ i ] , j ) ; cnt = Array . from ( { length : N } , ( _ , i ) => 0 ) ; for ( let i = 0 ; i < n ; ++ i ) cnt [ b [ i ] ] = 1 ; for ( let i = 1 ; i < N ; ++ i ) for ( let j = i ; j < N ; j += i ) if ( cnt [ j ] > 0 ) second [ i ] = Math . max ( second [ i ] , j ) ; let x ; for ( x = N - 1 ; x >= 0 ; x -- ) if ( first [ x ] > 0 && second [ x ] > 0 ) break ; document . write ( first [ x ] + " " + second [ x ] ) ; } let a = [ 3 , 1 , 4 , 2 , 8 ] ; let b = [ 5 , 2 , 12 , 8 , 3 ] ; let n = a . length ; let N = 20 ; gcdMax ( a , b , n , N ) ;

Index/key variables: i, j, x
Accumulator variables: j, x
Iterator variables: i, j, x
Javascript program:
function printPierpont ( n ) { var arr = Array ( n + 1 ) . fill ( false ) ; var two = 1 , three = 1 ; while ( two + 1 < n ) { arr [ two ] = true ; while ( two * three + 1 < n ) { arr [ three ] = true ; arr [ two * three ] = true ; three *= 3 ; } three = 1 ; two *= 2 ; } var v = [ ] ; for ( var i = 0 ; i < n ; i ++ ) if ( arr [ i ] ) v . push ( i + 1 ) ; arr = Array ( n + 1 ) . fill ( false ) ; for ( var p = 2 ; p * p < n ; p ++ ) { if ( arr [ p ] == false ) for ( var i = p * 2 ; i < n ; i += p ) arr [ i ] = true ; } for ( var i = 0 ; i < v . length ; i ++ ) if ( ! arr [ v [ i ] ] ) document . write ( v [ i ] + " " ) ; } var n = 200 ; printPierpont ( n ) ;

Index/key variables: i, p, three, two
Accumulator variables: i, p, three, two
Iterator variables: i, p
Javascript program:
function isWoodall ( x ) { if ( x % 2 == 0 ) return false ; if ( x == 1 ) return true ; x ++ ; let p = 0 ; while ( x % 2 == 0 ) { x = x / 2 ; p ++ ; if ( p == x ) return true ; } return false ; } let x = 383 ; if ( isWoodall ( x ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: p, x
Javascript program:
function print_result ( a , n , k , m ) { var v = Array . from ( Array ( m ) , ( ) => Array ( ) ) ; for ( var i = 0 ; i < n ; i ++ ) { var rem = a [ i ] % m ; v [ rem ] . push ( a [ i ] ) ; if ( v [ rem ] . length == k ) { for ( var j = 0 ; j < k ; j ++ ) document . write ( v [ rem ] [ j ] + " " ) ; return ; } } document . write ( " " ) ; } var a = [ 1 , 8 , 4 ] ; var n = a . length ; print_result ( a , n , 2 , 3 ) ;

Index/key variables: i, j, rem
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function PrimeDigitNumber ( N , size ) { let ans = new Array ( size ) ; let ns = 0 ; let small = 0 ; let i ; let p = [ 0 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 0 ] ; let prevprime = [ 0 , 0 , 0 , 2 , 3 , 3 , 5 , 5 , 7 , 7 ] ; if ( size == 1 ) { ans [ 0 ] = String . fromCharCode ( prevprime [ N [ 0 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] + ' ' . charCodeAt ( 0 ) ) ; ans [ 1 ] = ' \0 ' ; return ans ; } if ( N [ 0 ] == ' ' ) { for ( i = 0 ; i < size - 1 ; i ++ ) ans [ i ] = ' ' ; ans [ size - 1 ] = ' \0 ' ; return ans ; } for ( i = 0 ; i < size && small == 0 ; i ++ ) { if ( p [ N [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 1 ) { ans [ ns ++ ] = N [ i ] ; } else { if ( p [ N [ i ] - ' ' ] == 0 && prevprime [ N [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] != 0 ) { ans [ ns ++ ] = String . fromCharCode ( prevprime [ N [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] + ' ' . charCodeAt ( 0 ) ) ; small = 1 ; } else if ( p [ N [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 0 && prevprime [ N [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 0 ) { let j = i ; while ( j > 0 && p [ N [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 0 && prevprime [ N [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 0 ) { ans [ j ] = N [ j ] = ' ' ; N [ j - 1 ] = String . fromCharCode ( prevprime [ N [ j - 1 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] + ' ' . charCodeAt ( 0 ) ) ; ans [ j - 1 ] = N [ j - 1 ] ; small = 1 ; j -- ; } i = ns ; } } } if ( small == 0 ) { if ( prevprime [ N [ size - 1 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] + ' ' . charCodeAt ( 0 ) != ' ' . charCodeAt ( 0 ) ) ans [ size - 1 ] = String . fromCharCode ( prevprime [ N [ size - 1 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] + ' ' . charCodeAt ( 0 ) ) ; else { let j = size - 1 ; while ( j > 0 && prevprime [ N [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 0 ) { ans [ j ] = N [ j ] = ' ' ; N [ j - 1 ] = String . fromCharCode ( prevprime [ N [ j - 1 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] + ' ' . charCodeAt ( 0 ) ) ; ans [ j - 1 ] = N [ j - 1 ] ; small = 1 ; j -- ; } } } for ( ; ns < size ; ns ++ ) ans [ ns ] = ' ' ; ans [ ns ] = ' \0 ' ; let k = 0 ; while ( ans [ k ] == ' ' ) k ++ ; return ans . join ( " " ) ; } let N = " " . split ( " " ) ; let size = N . length ; document . write ( PrimeDigitNumber ( N , size ) . join ( " " ) ) ;

Index/key variables: i, j, k, ns
Accumulator variables: i, j, k, ns
Iterator variables: i
Javascript program:
function smallestX ( n ) { let temp = Array . from ( { length : 10 } , ( _ , i ) => 0 ) ; for ( let i = 0 ; i < 10 ; i ++ ) temp [ i ] = 0 ; if ( n == 0 ) return - 1 ; let count = 0 , x = 0 ; for ( x = 1 ; count < 10 ; x ++ ) { let y = x * n ; while ( y > 0 ) { if ( temp [ y % 10 ] == 0 ) { count ++ ; temp [ y % 10 ] = 1 ; } y /= 10 ; } } return x - 1 ; } let n = 5 ; document . write ( smallestX ( n ) ) ;

Index/key variables: i
Accumulator variables: count, i, x, y
Iterator variables: i, x
Javascript program:
function digSum ( n ) { let sum = 0 , rem = 0 ; while ( n > 0 ) { rem = n % 10 ; sum += rem ; n = Math . floor ( n / 10 ) ; } return sum ; } function findX ( n ) { for ( let i = 0 ; i <= n ; i ++ ) if ( i + digSum ( i ) == n ) return i ; return - 1 ; } let n = 43 ; document . write ( " " + findX ( n ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function complement ( number ) { number = number . split ( ' ' ) for ( let i = 0 ; i < number . length ; i ++ ) { if ( number [ i ] != ' ' ) { number [ i ] = String ( 9 - Number ( number [ i ] ) + 0 ) ; } } number = number . join ( " " ) document . write ( " " + number ) ; } let number = " " ; complement ( number ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countWays ( n ) { let count = 0 ; for ( let i = 1 ; i * i < n ; i ++ ) if ( n % i == 0 ) count ++ ; return count ; } let n = 12 ; document . write ( countWays ( n ) ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function isDigitPresent ( m , hash ) { while ( m > 0 ) { if ( hash [ m % 10 ] ) return true ; m = Math . floor ( m / 10 ) ; } return false ; } function countDivisibles ( n ) { let hash = Array . from ( { length : 10 } , ( _ , i ) => 0 ) ; let m = n ; while ( m > 0 ) { hash [ m % 10 ] = true ; m = Math . floor ( m / 10 ) ; } let ans = 0 ; for ( let i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( isDigitPresent ( i , hash ) ) ans ++ ; if ( n / i != i ) { if ( isDigitPresent ( n / i , hash ) ) ans ++ ; } } } return ans ; } let n = 15 ; document . write ( countDivisibles ( n ) ) ;

Accumulator variables: ans, i
Iterator variables: i
Javascript program:
var s = " " ; function luDecomposition ( mat , n ) { var lower = Array ( n ) . fill ( 0 ) . map ( x => Array ( n ) . fill ( 0 ) ) ; var upper = Array ( n ) . fill ( 0 ) . map ( x => Array ( n ) . fill ( 0 ) ) ; for ( var i = 0 ; i < n ; i ++ ) { for ( var k = i ; k < n ; k ++ ) { var sum = 0 ; for ( var j = 0 ; j < i ; j ++ ) sum += ( lower [ i ] [ j ] * upper [ j ] [ k ] ) ; upper [ i ] [ k ] = mat [ i ] [ k ] - sum ; } for ( var k = i ; k < n ; k ++ ) { if ( i == k ) lower [ i ] [ i ] = 1 ; else { var sum = 0 ; for ( var j = 0 ; j < i ; j ++ ) sum += ( lower [ k ] [ j ] * upper [ j ] [ i ] ) ; lower [ k ] [ i ] = parseInt ( ( mat [ k ] [ i ] - sum ) / upper [ i ] [ i ] ) ; } } } document . write ( setw ( 2 ) + " " + setw ( 10 ) + " " ) ; for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j < n ; j ++ ) document . write ( setw ( 4 ) + lower [ i ] [ j ] + " " ) ; document . write ( setw ( 10 ) ) ; for ( var j = 0 ; j < n ; j ++ ) document . write ( setw ( 4 ) + upper [ i ] [ j ] + " " ) ; document . write ( " " ) ; } } function setw ( noOfSpace ) { var s = " " ; for ( i = 0 ; i < noOfSpace ; i ++ ) s += " " ; return s ; } var mat = [ [ 2 , - 1 , - 2 ] , [ - 4 , 6 , 3 ] , [ - 4 , - 2 , 8 ] ] ; luDecomposition ( mat , 3 ) ;

Index/key variables: i, j, k
Accumulator variables: i, j, k, s, sum
Iterator variables: i, j, k
Javascript program:
function printTwoDivisibleParts ( num , f , s ) { var N = num . length ; var prefixReminder = [ ] var suffixReminder = [ ] suffixReminder [ 0 ] = 0 ; for ( var i = 1 ; i < N ; i ++ ) suffixReminder [ i ] = ( suffixReminder [ i - 1 ] * 10 + ( num [ i - 1 ] - ' ' ) ) % f ; prefixReminder [ N ] = 0 ; var base1 = 1 ; for ( var i = N - 1 ; i >= 0 ; i -- ) { prefixReminder [ i ] = ( prefixReminder [ i + 1 ] + ( num [ i ] - ' ' ) * base1 ) % s ; base1 = ( base1 * 10 ) % s ; } for ( var i = 0 ; i < N ; i ++ ) { if ( prefixReminder [ i ] == 0 && suffixReminder [ i ] == 0 && num [ i ] != ' ' ) { document . write ( num . substring ( 0 , i ) + " " + num . substring ( i ) ) ; return ; } } document . write ( " " ) ; } var num = " " ; var f = 12345 ; var s = 1024 ; printTwoDivisibleParts ( num , f , s ) ;

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function calculate ( a , n ) { let ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let r = i + 1 ; for ( let j = r ; j < n ; j ++ ) { if ( a [ i ] == a [ j ] ) r += 1 ; else break ; } let d = r - i ; ans += ( d * ( d + 1 ) / 2 ) ; i = r - 1 ; } return ans ; } let a = [ 2 , 4 , 5 , 3 , 3 , 3 ] ; document . write ( calculate ( a , a . length ) ) ;

Index/key variables: i, j
Accumulator variables: ans, i, j, r
Iterator variables: i, j
Javascript program:
function sum ( n ) { var rem = 0 ; var sum_of_digits = 0 ; while ( n > 0 ) { rem = n % 10 ; sum_of_digits += rem ; n = parseInt ( n / 10 ) ; } return sum_of_digits ; } function count ( n ) { var c = 0 ; for ( i = n - 97 ; i <= n ; i ++ ) { var a = sum ( i ) ; var b = sum ( a ) ; if ( ( i + a + b ) == n ) { c += 1 ; } } return c ; } var n = 9939 ; document . write ( count ( n ) ) ;

Accumulator variables: c, i, sum_of_digits
Iterator variables: i
Javascript program:
function isPowerOfK ( n , k ) { let oneSeen = false ; while ( n > 0 ) { let digit = n % k ; if ( digit > 1 ) return false ; if ( digit == 1 ) { if ( oneSeen ) return false ; oneSeen = true ; } n = Math . floor ( n / k ) ; } return true ; } let n = 64 , k = 4 ; if ( isPowerOfK ( n , k ) ) document . write ( " " ) ; else document . write ( " " ) ;

Boolean variables: oneSeen
Javascript program:
const MAX_DIGITS = 20 ; function isOctal ( n ) { while ( n ) { if ( ( n % 10 ) >= 8 ) return false ; else n = Math . floor ( n / 10 ) ; } return true ; } function isPalindrome ( n ) { var divide = ( isOctal ( n ) == false ) ? 8 : 10 ; var octal = new Array ( MAX_DIGITS ) ; var i = 0 ; while ( n != 0 ) { octal [ i ++ ] = n % divide ; n = Math . floor ( n / divide ) ; } for ( var j = i - 1 , k = 0 ; k <= j ; j -- , k ++ ) if ( octal [ j ] != octal [ k ] ) return false ; return true ; } var n = 97 ; if ( isPalindrome ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: j, k
Accumulator variables: i, j, k
Iterator variables: j
Javascript program:
function printFactorialNums ( n ) { let fact = 1 ; let x = 2 ; while ( fact <= n ) { document . write ( fact + " " ) ; fact = fact * x ; x ++ ; } } let n = 100 ; printFactorialNums ( n ) ;

Accumulator variables: x
Javascript program:
function isPrime ( n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( let i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } function isThreeDisctFactors ( n ) { let sq = parseInt ( Math . sqrt ( n ) ) ; if ( sq * sq != n ) return false ; return isPrime ( sq ) ? true : false ; } let num = 9 ; if ( isThreeDisctFactors ( num ) ) document . write ( " " ) ; else document . write ( " " ) ; num = 15 ; if ( isThreeDisctFactors ( num ) ) document . write ( " " ) ; else document . write ( " " ) ; num = 12397923568441 ; if ( isThreeDisctFactors ( num ) ) document . write ( " " ) ; else document . write ( " " ) ;

Iterator variables: i
Javascript program:
function computeLastDigit ( A , B ) { let variable = 1 ; return 1 ; else if ( ( B - A ) >= 5 ) return 0 ; else { for ( let i = A + 1 ; i <= B ; i ++ ) variable = ( variable * ( i % 10 ) ) % 10 ; return variable % 10 ; } } document . write ( computeLastDigit ( 2632 , 2634 ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function sumOfAP ( a , d , n ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { sum = sum + a ; a = a + d ; } return sum ; } let n = 20 ; let a = 2.5 , d = 1.5 ; document . write ( sumOfAP ( a , d , n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function multiplyFactors ( n ) { let M = 1000000007 ; let i ; prod = 1 ; for ( i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) prod = ( prod * i ) % M ; else { prod = ( prod * i ) % M ; prod = ( prod * n / i ) % M ; } } } return prod ; } n = 12 ; document . write ( multiplyFactors ( n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let M = 1000000007 ; function power ( x , y ) { let res = 1 ; while ( y > 0 ) { if ( y % 2 == 1 ) res = ( res * x ) % M ; y = ( y >> 1 ) % M ; x = ( x * x ) % M ; } return res ; } function countFactors ( n ) { let count = 0 ; for ( let i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) count ++ ; else count += 2 ; } } return count ; } function multiplyFactors ( n ) { let numFactor = countFactors ( n ) ; let product = power ( n , numFactor / 2 ) ; if ( numFactor % 2 == 1 ) product = ( product * Math . sqrt ( n ) ) % M ; return product ; } let n = 12 ; document . write ( multiplyFactors ( n ) ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function isDivisibleBy10 ( bin ) { let n = bin . length ; if ( bin [ n - 1 ] == ' ' ) return false ; let sum = 0 ; for ( let i = n - 2 ; i >= 0 ; i -- ) { if ( bin [ i ] == ' ' ) { let posFromRight = n - i - 1 ; if ( posFromRight % 4 == 1 ) sum = sum + 2 ; else if ( posFromRight % 4 == 2 ) sum = sum + 4 ; else if ( posFromRight % 4 == 3 ) sum = sum + 8 ; else if ( posFromRight % 4 == 0 ) sum = sum + 6 ; } } if ( sum % 10 == 0 ) return true ; return false ; } let bin = " " ; if ( isDivisibleBy10 ( bin ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function printTrib ( n ) { if ( n < 1 ) return ; let first = 0 , second = 0 ; let third = 1 ; document . write ( first + " " ) ; if ( n > 1 ) document . write ( second + " " ) ; if ( n > 2 ) document . write ( second + " " ) ; for ( let i = 3 ; i < n ; i ++ ) { let curr = first + second + third ; first = second ; second = third ; third = curr ; document . write ( curr + " " ) ; } } let n = 10 ; printTrib ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function SieveOfEratosthenes ( n ) { let prime = new Array ( n + 1 ) . fill ( true ) ; for ( let p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) for ( let i = p * 2 ; i < n + 1 ; i += p ) prime [ i ] = false ; } let lis = new Array ( ) ; for ( let p = 2 ; p <= n ; p ++ ) if ( prime [ p ] ) lis . push ( p ) ; return lis ; } function setBits ( n ) { let cnt = 0 ; while ( n ) { if ( n & 1 ) cnt ++ ; n >>= 1 ; } ; return cnt ; } let x = 4 ; let y = 8 ; let count = 0 ; let primeArr = SieveOfEratosthenes ( Math . ceil ( Math . log ( y , 2 ) ) ) ; for ( let i = x ; i < y + 1 ; i ++ ) { let temp = setBits ( i ) ; if ( primeArr . includes ( temp ) ) count += 1 ; } document . write ( count ) ;

Index/key variables: i, p
Accumulator variables: cnt, count, i, p
Iterator variables: i, p