dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function totalPairs ( s1 , s2 ) { var a1 = 0 , b1 = 0 ; for ( var i = 0 ; i < s1 . length ; i ++ ) { if ( ( s1 [ i ] . charCodeAt ( 0 ) ) % 2 != 0 ) a1 ++ ; else b1 ++ ; } var a2 = 0 , b2 = 0 ; for ( var i = 0 ; i < s2 . length ; i ++ ) { if ( ( s2 [ i ] . charCodeAt ( 0 ) ) % 2 != 0 ) a2 ++ ; else b2 ++ ; } return ( ( a1 * a2 ) + ( b1 * b2 ) ) ; } var s1 = " " , s2 = " " ; document . write ( totalPairs ( s1 , s2 ) ) ;

Index/key variables: i
Accumulator variables: a1, a2, b1, b2, i
Iterator variables: i
Javascript program:
function prefixOccurrences ( str ) { var c = str . charAt ( 0 ) ; var countc = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( str . charAt ( i ) == c ) countc ++ ; } return countc ; } var str = " " ; document . write ( prefixOccurrences ( str ) ) ;

Accumulator variables: countc, i
Iterator variables: i
Javascript program:
function minOperations ( s , t , n ) { var ct0 = 0 , ct1 = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( s [ i ] === t [ i ] ) continue ; if ( s [ i ] === " " ) ct0 ++ ; else ct1 ++ ; } return Math . max ( ct0 , ct1 ) ; } var s = " " , t = " " ; var n = s . length ; document . write ( minOperations ( s , t , n ) ) ;

Index/key variables: i
Accumulator variables: ct0, ct1, i
Iterator variables: i
Javascript program:
function decryptString ( str , n ) { let i = 0 , jump = 1 ; let decryptedStr = " " ; while ( i < n ) { decryptedStr += str [ i ] ; i += jump ; jump ++ ; } return decryptedStr ; } let str = " " ; let n = str . length ; document . write ( decryptString ( str , n ) ) ;

Index/key variables: i
Accumulator variables: decryptedStr, i, jump
Javascript program:
function SieveOfEratosthenes ( prime , p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( let p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( let i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } function sumProdOfPrimeFreq ( s ) { let prime = new Array ( s . length + 1 ) ; prime . fill ( true ) ; SieveOfEratosthenes ( prime , s . length + 1 ) ; let i , j ; let m = new Map ( ) ; for ( i = 0 ; i < s . length ; i ++ ) m . set ( s [ i ] , m . get ( s [ i ] ) == null ? 1 : m . get ( s [ i ] ) + 1 ) ; let sum = 0 , product = 1 ; for ( let it of m ) { console . log ( m ) if ( prime [ it [ 1 ] ] ) { sum += it [ 1 ] ; product *= it [ 1 ] ; } } document . write ( " " + sum ) ; document . write ( " " + product ) ; } let s = " " ; sumProdOfPrimeFreq ( s ) ;

Index/key variables: i, p
Accumulator variables: i, p, product, sum
Iterator variables: i, it, p
Javascript program:
function multipleOrFactor ( s1 , s2 ) { let m1 = new Map ( ) ; let m2 = new Map ( ) ; for ( let i = 0 ; i < s1 . length ; i ++ ) { if ( m1 [ s1 [ i ] ] ) m1 [ s1 [ i ] ] ++ ; else m1 [ s1 [ i ] ] = 1 } for ( let i = 0 ; i < s2 . length ; i ++ ) { if ( m2 [ s2 [ i ] ] ) m2 [ s2 [ i ] ] ++ ; else m2 [ s2 [ i ] ] = 1 } for ( var it in m1 ) { if ( ! ( m2 [ it ] ) ) continue ; if ( m2 [ it ] % m1 [ it ] == 0 m1 [ it ] % m2 [ it ] == 0 ) continue ; else return false ; } return true ; } let s1 = " " ; let s2 = " " ; multipleOrFactor ( s1 , s2 ) ? document . write ( " " ) : document . write ( " " ) ;

Index/key variables: i, it
Accumulator variables: i
Iterator variables: i, it
Javascript program:
function solve ( s ) { let m = new Map ( ) ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( m . has ( s [ i ] ) ) m . set ( s [ i ] , m . get ( s [ i ] ) + 1 ) ; else m . set ( s [ i ] , 1 ) ; } let new_string = " " ; for ( let i = 0 ; i < s . length ; i ++ ) { if ( m . get ( s [ i ] ) % 2 == 0 ) continue ; new_string = new_string + s [ i ] ; } document . write ( new_string ) ; } let s = " " ; solve ( s ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isPalindrome ( str ) { var i = 0 , j = str . length - 1 ; while ( i < j ) if ( str [ i ++ ] != str [ j -- ] ) return false ; return true ; } function removePalinWords ( str ) { var final_str = " " , word = " " ; str = str + " " ; var n = str . length ; for ( var i = 0 ; i < n ; i ++ ) { if ( str [ i ] != ' ' ) word = word + str [ i ] ; else { if ( ! ( isPalindrome ( word ) ) ) final_str += word + " " ; word = " " ; } } return final_str ; } var str = " " ; document . write ( removePalinWords ( str ) ) ;

Index/key variables: i
Accumulator variables: final_str, i, j
Iterator variables: i
Javascript program:
function findSubSequence ( s , num ) { let res = 0 ; let i = 0 ; while ( num > 0 ) { if ( ( num & 1 ) == 1 ) res += s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; i ++ ; num = num >> 1 ; } return res ; } function combinedSum ( s ) { let n = s . length ; let c_sum = 0 ; let range = ( 1 << n ) - 1 ; for ( let i = 0 ; i <= range ; i ++ ) c_sum += findSubSequence ( s , i ) ; return c_sum ; } let s = " " ; document . write ( combinedSum ( s ) ) ;

Index/key variables: i
Accumulator variables: c_sum, i, res
Iterator variables: i
Javascript program:
var MAX_CHAR = 26 ; function findSubsequence ( str , k ) { var a = Array ( MAX_CHAR ) . fill ( 0 ) ; for ( var i = 0 ; i < str . length ; i ++ ) a [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( var i = 0 ; i < str . length ; i ++ ) if ( a [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] >= k ) document . write ( str [ i ] ) ; } var k = 2 ; findSubsequence ( " " , k ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function convert ( str ) { var w = " " , z = " " ; str = str . toUpperCase ( ) + " " ; for ( i = 0 ; i < str . length ; i ++ ) { var ch = str [ i ] ; if ( ch != ' ' ) w = w + ch ; else { z = z + ( w [ 0 ] . toLowerCase ( ) ) + w . substring ( 1 ) + " " ; w = " " ; } } return z ; } var str = " " ; document . write ( convert ( str ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isVowel ( c ) { return c === " " || c === " " || c === " " || c === " " || c === " " ; } function encryptString ( s , n , k ) { var cv = new Array ( n ) . fill ( 0 ) ; var cc = new Array ( n ) . fill ( 0 ) ; if ( isVowel ( s [ 0 ] ) ) cv [ 0 ] = 1 ; else cc [ 0 ] = 1 ; for ( var i = 1 ; i < n ; i ++ ) { cv [ i ] = cv [ i - 1 ] + ( isVowel ( s [ i ] ) === true ? 1 : 0 ) ; cc [ i ] = cc [ i - 1 ] + ( isVowel ( s [ i ] ) === true ? 0 : 1 ) ; } var ans = " " ; var prod = 0 ; prod = cc [ k - 1 ] * cv [ k - 1 ] ; ans += prod ; for ( var i = k ; i < s . length ; i ++ ) { prod = ( cc [ i ] - cc [ i - k ] ) * ( cv [ i ] - cv [ i - k ] ) ; ans += prod ; } return ans ; } var s = " " ; var n = s . length ; var k = 2 ; document . write ( encryptString ( s . split ( " " ) , n , k ) + " " ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function countOccurrences ( str , word ) { let a = str . split ( " " ) ; let count = 0 ; for ( let i = 0 ; i < a . length ; i ++ ) { if ( word == ( a [ i ] ) ) count ++ ; } return count ; } let str = " " ; let word = " " ; document . write ( countOccurrences ( str , word ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function permute ( input ) { var n = input . length ; var max = 1 << n ; input = input . toLowerCase ( ) ; for ( var i = 0 ; i < max ; i ++ ) { var combination = input . split ( ' ' ) ; for ( var j = 0 ; j < n ; j ++ ) { if ( ( ( i >> j ) & 1 ) == 1 ) combination [ j ] = String . fromCharCode ( combination [ j ] . charCodeAt ( 0 ) - 32 ) ; } document . write ( combination . join ( ' ' ) ) ; document . write ( " " ) ; } } permute ( " " ) ;

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function printString ( str , ch , count ) { var occ = 0 , i ; if ( count == 0 ) { document . write ( str ) ; return ; } for ( i = 0 ; i < str . length ; i ++ ) { if ( str . charAt ( i ) == ch ) occ ++ ; if ( occ == count ) break ; } if ( i < str . length - 1 ) document . write ( str . substring ( i + 1 ) ) ; else document . write ( " " ) ; } var str = " " ; printString ( str , ' ' , 2 ) ;

Accumulator variables: i, occ
Iterator variables: i
Javascript program:
function isVowel ( c ) { return ( c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' ) ; } function reverseVowel ( str ) { let i = 0 ; let j = str . length - 1 ; let str1 = str . split ( " " ) ; while ( i < j ) { if ( ! isVowel ( str1 [ i ] ) ) { i ++ ; continue ; } if ( ! isVowel ( str1 [ j ] ) ) { j -- ; continue ; } let t = str1 [ i ] ; str1 [ i ] = str1 [ j ] ; str1 [ j ] = t ; i ++ ; j -- ; } let str2 = ( str1 ) . join ( " " ) ; return str2 ; } let str = " " ; document . write ( reverseVowel ( str ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Javascript program:
function isPalindrome ( str ) { let l = 0 ; let h = str . length - 1 ; while ( h > l ) if ( str [ l ++ ] != str [ h -- ] ) return false ; return true ; } function minRemovals ( str ) { if ( str [ 0 ] == ' ' ) return 0 ; if ( isPalindrome ( str ) ) return 1 ; return 2 ; } document . write ( minRemovals ( " " ) + " " ) ; document . write ( minRemovals ( " " ) ) ;

Accumulator variables: h, l
Javascript program:
function power ( x , y , p ) { var res = 1 ; x = x % p ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } function findModuloByM ( X , N , M ) { if ( N < 6 ) { var temp = " " ; for ( var i = 1 ; i < N ; i ++ ) { temp += String . fromCharCode ( 48 + X ) ; } var res = parseInt ( temp ) % M ; return res ; } if ( N % 2 == 0 ) { var half = findModuloByM ( X , N / 2 , M ) % M ; var res = ( half * power ( 10 , N / 2 , M ) + half ) % M ; return res ; } else { var half = findModuloByM ( X , N / 2 , M ) % M ; var res = ( half * power ( 10 , N / 2 + 1 , M ) + half * 10 + X ) % M ; return res ; } } var X = 6 , N = 14 , M = 9 ; document . write ( findModuloByM ( X , N , M ) ) ;

Accumulator variables: i, temp
Iterator variables: i
Javascript program:
class circle { constructor ( x , y , r ) { this . x = x ; this . y = y ; this . r = r ; } } function check ( C ) { let C1C2 = Math . sqrt ( ( C [ 1 ] . x - C [ 0 ] . x ) * ( C [ 1 ] . x - C [ 0 ] . x ) + ( C [ 1 ] . y - C [ 0 ] . y ) * ( C [ 1 ] . y - C [ 0 ] . y ) ) ; let flag = false ; if ( C1C2 < ( C [ 0 ] . r + C [ 1 ] . r ) ) { if ( ( C [ 0 ] . x + C [ 1 ] . x ) == 2 * C [ 2 ] . x && ( C [ 0 ] . y + C [ 1 ] . y ) == 2 * C [ 2 ] . y ) { flag = true ; } } return flag ; } function IsFairTriplet ( c ) { let f = false ; f |= check ( c ) ; for ( let i = 0 ; i < 2 ; i ++ ) { swap ( c [ 0 ] , c [ 2 ] ) ; f |= check ( c ) ; } return f ; } function swap ( circle1 , circle2 ) { let temp = circle1 ; circle1 = circle2 ; circle2 = temp ; } let C = new Array ( 3 ) ; C [ 0 ] = new circle ( 0 , 0 , 8 ) ; C [ 1 ] = new circle ( 0 , 10 , 6 ) ; C [ 2 ] = new circle ( 0 , 5 , 5 ) ; if ( IsFairTriplet ( C ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: f, i
Iterator variables: i
Boolean variables: f, flag
Class/struct names: circle
Javascript program:
function eccHyperbola ( A , B ) { let r = B * B / A * A ; r += 1 ; return Math . sqrt ( r ) ; } let A = 3.0 ; let B = 2.0 ; document . write ( eccHyperbola ( A , B ) ) ;

Accumulator variables: r
Javascript program:
function distance ( m , n , p , q ) { return Math . sqrt ( Math . pow ( n - m , 2 ) + Math . pow ( q - p , 2 ) * 1.0 ) ; } function Excenters ( x1 , y1 , x2 , y2 , x3 , y3 ) { var a = distance ( x2 , x3 , y2 , y3 ) ; var b = distance ( x3 , x1 , y3 , y1 ) ; var c = distance ( x1 , x2 , y1 , y2 ) ; var excenter = new Array ( 4 ) ; for ( var i = 0 ; i < 4 ; i ++ ) excenter [ i ] = new Array ( 2 ) ; excenter [ 1 ] [ 0 ] = ( - ( a * x1 ) + ( b * x2 ) + ( c * x3 ) ) / ( - a + b + c ) ; excenter [ 1 ] [ 1 ] = ( - ( a * y1 ) + ( b * y2 ) + ( c * y3 ) ) / ( - a + b + c ) ; excenter [ 2 ] [ 0 ] = ( ( a * x1 ) - ( b * x2 ) + ( c * x3 ) ) / ( a - b + c ) ; excenter [ 2 ] [ 1 ] = ( ( a * y1 ) - ( b * y2 ) + ( c * y3 ) ) / ( a - b + c ) ; excenter [ 3 ] [ 0 ] = ( ( a * x1 ) + ( b * x2 ) - ( c * x3 ) ) / ( a + b - c ) ; excenter [ 3 ] [ 1 ] = ( ( a * y1 ) + ( b * y2 ) - ( c * y3 ) ) / ( a + b - c ) ; for ( var i = 1 ; i <= 3 ; i ++ ) { document . write ( excenter [ i ] [ 0 ] + " " + excenter [ i ] [ 1 ] + " " ) ; } } var x1 , x2 , x3 , y1 , y2 , y3 ; x1 = 0 ; x2 = 3 ; x3 = 0 ; y1 = 0 ; y2 = 0 ; y3 = 4 ; Excenters ( x1 , y1 , x2 , y2 , x3 , y3 ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countPairs ( P , Q , N , M ) { var A = [ 0 , 0 ] , B = [ 0 , 0 ] ; for ( var i = 0 ; i < N ; i ++ ) A [ P [ i ] % 2 ] ++ ; for ( var i = 0 ; i < M ; i ++ ) B [ Q [ i ] % 2 ] ++ ; return ( A [ 0 ] * B [ 0 ] + A [ 1 ] * B [ 1 ] ) ; } var P = [ 1 , 3 , 2 ] , Q = [ 3 , 0 ] ; var N = P . length ; var M = Q . length ; document . write ( countPairs ( P , Q , N , M ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function convertToASCII ( N ) { let num = N . toString ( ) ; for ( let ch = 0 ; ch < num . length ; ch ++ ) { document . write ( num [ ch ] + " " + num [ ch ] . charCodeAt ( 0 ) + " " ) ; } } let N = 36 ; convertToASCII ( N ) ;

Index/key variables: ch
Accumulator variables: ch
Iterator variables: ch
Javascript program:
function productExceptSelf ( arr , N ) { let product = 1 ; let z = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( arr [ i ] != 0 ) product *= arr [ i ] ; if ( arr [ i ] == 0 ) z += 1 ; } let a = Math . abs ( product ) ; for ( let i = 0 ; i < N ; i ++ ) { if ( z == 1 ) { if ( arr [ i ] != 0 ) arr [ i ] = 0 ; else arr [ i ] = product ; continue ; } else if ( z > 1 ) { arr [ i ] = 0 ; continue ; } let b = Math . abs ( arr [ i ] ) ; let curr = Math . round ( Math . exp ( Math . log ( a ) - Math . log ( b ) ) ) ; if ( arr [ i ] < 0 && product < 0 ) arr [ i ] = curr ; else if ( arr [ i ] > 0 && product > 0 ) arr [ i ] = curr ; else arr [ i ] = - 1 * curr ; } for ( let i = 0 ; i < N ; i ++ ) { document . write ( arr [ i ] + " " ) ; } } let arr = [ 10 , 3 , 5 , 6 , 2 ] ; let N = arr . length ; productExceptSelf ( arr , N ) ;

Index/key variables: i
Accumulator variables: i, product, z
Iterator variables: i
Javascript program:
function singleDigitSubarrayCount ( arr , N ) { let res = 0 ; let count = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( arr [ i ] <= 9 ) { count ++ ; res += count ; } else { count = 0 ; } } document . write ( res ) ; } let arr = [ 0 , 1 , 14 , 2 , 5 ] ; let N = arr . length ; singleDigitSubarrayCount ( arr , N ) ;

Index/key variables: i
Accumulator variables: count, i, res
Iterator variables: i
Javascript program:
function isPossible ( N ) { return ( ( ( N & ( N - 1 ) ) & N ) ) ; } function countElements ( N ) { var count = 0 ; for ( i = 1 ; i <= N ; i ++ ) { if ( isPossible ( i ) != 0 ) count ++ ; } document . write ( count ) ; } var N = 15 ; countElements ( N ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function countElements ( N ) { var Cur_Ele = 1 ; var Count = 0 ; while ( Cur_Ele <= N ) { Count ++ ; Cur_Ele = Cur_Ele * 2 ; } document . write ( N - Count ) ; } var N = 15 ; countElements ( N ) ;

Accumulator variables: Count
Javascript program:
function maxAdjacent ( arr , N ) { let res = [ ] ; let arr_max = Number . MIN_VALUE ; for ( let i = 1 ; i < N ; i ++ ) { arr_max = Math . max ( arr_max , Math . abs ( arr [ i - 1 ] - arr [ i ] ) ) ; } for ( let i = 1 ; i < N - 1 ; i ++ ) { let curr_max = Math . abs ( arr [ i - 1 ] - arr [ i + 1 ] ) ; let ans = Math . max ( curr_max , arr_max ) ; res . push ( ans ) ; } document . write ( res . join ( " " ) ) ; } let arr = [ 1 , 3 , 4 , 7 , 8 ] ; let N = arr . length ; maxAdjacent ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function minimumIncrement ( arr , N ) { if ( N % 2 != 0 ) { document . write ( " " ) ; System . exit ( 0 ) ; } var cntEven = 0 ; var cntOdd = 0 ; for ( i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { cntEven += 1 ; } } cntOdd = N - cntEven ; return Math . abs ( cntEven - cntOdd ) / 2 ; } var arr = [ 1 , 3 , 4 , 9 ] ; var N = arr . length ; document . write ( minimumIncrement ( arr , N ) ) ;

Index/key variables: i
Accumulator variables: cntEven, i
Iterator variables: i
Javascript program:
function cntWaysConsArray ( A , N ) { var total = 1 ; var oddArray = 1 ; for ( i = 0 ; i < N ; i ++ ) { total = total * 3 ; if ( A [ i ] % 2 == 0 ) { oddArray *= 2 ; } } document . write ( total - oddArray ) ; } var A = [ 2 , 4 ] ; var N = A . length ; cntWaysConsArray ( A , N ) ;

Index/key variables: i
Accumulator variables: i, oddArray
Iterator variables: i
Javascript program:
function countNumberHavingKthBitSet ( N , K ) { let numbers_rightmost_setbit_K = 0 ; for ( let i = 1 ; i <= K ; i ++ ) { let numbers_rightmost_bit_i = ( N + 1 ) / 2 ; N -= numbers_rightmost_bit_i ; if ( i == K ) { numbers_rightmost_setbit_K = numbers_rightmost_bit_i ; } } document . write ( numbers_rightmost_setbit_K ) ; } let N = 15 ; let K = 2 ; countNumberHavingKthBitSet ( N , K ) ;

Accumulator variables: N, i
Iterator variables: i
Javascript program:
function countSetBits ( N ) { let count = 0 ; while ( N != 0 ) { N = N & ( N - 1 ) ; count ++ ; } return count ; } let N = 4 ; let bits = countSetBits ( N ) ; document . write ( " " + " " + ( Math . pow ( 2 , bits ) ) + " " ) ; document . write ( " " + " " + ( N + 1 - ( Math . pow ( 2 , bits ) ) ) ) ;

Accumulator variables: count
Javascript program:
function minMoves ( arr , N ) { var odd_element_cnt = 0 ; var i ; for ( i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 != 0 ) { odd_element_cnt ++ ; } } var moves = Math . floor ( ( odd_element_cnt ) / 2 ) ; if ( odd_element_cnt % 2 != 0 ) moves += 2 ; document . write ( moves ) ; } var arr = [ 5 , 6 , 3 , 7 , 20 ] ; N = arr . length ; minMoves ( arr , N ) ;

Index/key variables: i
Accumulator variables: i, moves, odd_element_cnt
Iterator variables: i
Javascript program:
function minimumSubsetDifference ( N ) { let blockOfSize8 = N / 8 ; let str = " " ; let subsetDifference = 0 ; let partition = " " ; while ( blockOfSize8 -- > 0 ) { partition += str ; } let A = [ ] ; let B = [ ] ; let x = 0 , y = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( partition [ i ] == ' ' ) { A [ x ++ ] = ( ( i + 1 ) * ( i + 1 ) ) ; } else { B [ y ++ ] = ( ( i + 1 ) * ( i + 1 ) ) ; } } document . write ( subsetDifference + " " ) ; for ( let i = 0 ; i < x ; i ++ ) document . write ( A [ i ] + " " ) ; document . write ( " " ) ; for ( let i = 0 ; i < y ; i ++ ) document . write ( B [ i ] + " " ) ; } let N = 8 ; minimumSubsetDifference ( N ) ;

Index/key variables: i
Accumulator variables: blockOfSize8, i, partition, x, y
Iterator variables: i
Javascript program:
function findTheGreatestX ( P , Q ) { var divisiors = new Map ( ) ; for ( var i = 2 ; i * i <= Q ; i ++ ) { while ( Q % i == 0 && Q > 1 ) { Q = parseInt ( Q / i ) ; if ( divisiors . has ( i ) ) divisiors . set ( i , divisiors . get ( i ) + 1 ) else divisiors . set ( i , 1 ) } } if ( Q > 1 ) if ( divisiors . has ( Q ) ) divisiors . set ( Q , divisiors . get ( Q ) + 1 ) else divisiors . set ( Q , 1 ) var ans = 0 ; divisiors . forEach ( ( value , key ) => { var frequency = value ; var temp = P ; var cur = 0 ; while ( temp % key == 0 ) { temp = parseInt ( temp / key ) ; cur ++ ; } if ( cur < frequency ) { ans = P ; } temp = P ; for ( var j = cur ; j >= frequency ; j -- ) { temp = parseInt ( temp / key ) ; } ans = Math . max ( temp , ans ) ; } ) ; document . write ( ans ) ; } var P = 10 , Q = 4 ; findTheGreatestX ( P , Q ) ;

Accumulator variables: cur, i, j
Iterator variables: i, j
Javascript program:
function checkRearrangements ( mat , N , M ) { for ( let i = 0 ; i < N ; i ++ ) { for ( let j = 1 ; j < M ; j ++ ) { if ( mat [ i ] [ 0 ] != mat [ i ] [ j ] ) { return " " ; } } } return " " ; } function nonZeroXor ( mat , N , M ) { let res = 0 ; for ( let i = 0 ; i < N ; i ++ ) { res = res ^ mat [ i ] [ 0 ] ; } if ( res != 0 ) return " " ; else return checkRearrangements ( mat , N , M ) ; } let mat = [ [ 1 , 1 , 2 ] , [ 2 , 2 , 2 ] , [ 3 , 3 , 3 ] ] ; let N = mat . length ; let M = mat [ 0 ] . length ; document . write ( nonZeroXor ( mat , N , M ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
var size_int = 32 ; function functionMax ( arr , n ) { var setBit = Array . from ( Array ( 32 ) , ( ) => new Array ( ) ) ; for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j < size_int ; j ++ ) { if ( arr [ i ] & ( 1 << j ) ) setBit [ j ] . push ( i ) ; } } for ( var i = size_int - 1 ; i >= 0 ; i -- ) { if ( setBit [ i ] . length == 1 ) { [ arr [ 0 ] , arr [ setBit [ i ] [ 0 ] ] ] = [ arr [ setBit [ i ] [ 0 ] ] , arr [ 0 ] ] ; break ; } } var maxAnd = arr [ 0 ] ; for ( var i = 1 ; i < n ; i ++ ) { maxAnd = maxAnd & ( ~ arr [ i ] ) ; } return maxAnd ; } var arr = [ 1 , 2 , 4 , 8 , 16 ] ; var n = arr . length ; document . write ( functionMax ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function nCr ( n , r ) { let res = 1 ; if ( r > n - r ) r = n - r ; for ( let i = 0 ; i < r ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } function solve ( n , m , k ) { let sum = 0 ; for ( let i = 0 ; i <= k ; i ++ ) sum += nCr ( n , i ) * nCr ( m , k - i ) ; return sum ; } let n = 3 , m = 2 , k = 2 ; document . write ( solve ( n , m , k ) ) ;

Accumulator variables: i, res, sum
Iterator variables: i
Javascript program:
function findMaximumGcd ( n ) { let max_gcd = 1 ; for ( let i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { if ( i > max_gcd ) max_gcd = i ; if ( ( n / i != i ) && ( n / i != n ) && ( ( n / i ) > max_gcd ) ) max_gcd = n / i ; } } return max_gcd ; } let N = 10 ; document . write ( findMaximumGcd ( N ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let x = 2000021 let v = new Array ( x ) ; function sieve ( ) { v [ 1 ] = 1 ; for ( let i = 2 ; i < x ; i ++ ) v [ i ] = i ; for ( let i = 4 ; i < x ; i += 2 ) v [ i ] = 2 ; for ( let i = 3 ; i * i < x ; i ++ ) { if ( v [ i ] == i ) { for ( let j = i * i ; j < x ; j += i ) { if ( v [ j ] == j ) { v [ j ] = i ; } } } } } function prime_factors ( n ) { let s = new Set ( ) ; while ( n != 1 ) { s . add ( v [ n ] ) ; n = n / v [ n ] ; } return s . size ; } function distinctPrimes ( m , k ) { let result = new Array ( ) ; for ( let i = 14 ; i < m + k ; i ++ ) { let count = prime_factors ( i ) ; if ( count == k ) { result . push ( i ) ; } } let p = result . length ; for ( let index = 0 ; index < p - 1 ; index ++ ) { let element = result [ index ] ; let count = 1 , z = index ; while ( z < p - 1 && count <= k && result [ z ] + 1 == result [ z + 1 ] ) { count ++ ; z ++ ; } if ( count >= k ) document . write ( element + ' ' ) ; } } sieve ( ) ; let N = 1000 , K = 3 ; distinctPrimes ( N , K ) ;

Index/key variables: i, index, j, n, z
Accumulator variables: count, i, index, j, z
Iterator variables: i, index, j
Javascript program:
function sigma ( n ) { if ( n == 1 ) return 1 ; var result = 0 ; for ( var i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == ( n / i ) ) result += i ; else result += ( i + n / i ) ; } } return ( result + n + 1 ) ; } function isSuperabundant ( N ) { for ( var i = 1 ; i < N ; i ++ ) { var x = sigma ( i ) / i ; var y = sigma ( N ) / ( N * 1.0 ) ; if ( x > y ) return false ; } return true ; } var N = 4 ; isSuperabundant ( N ) ? document . write ( " " ) : document . write ( " " ) ;

Accumulator variables: i, result
Iterator variables: i
Javascript program:
function isDNum ( n ) { if ( n < 4 ) return false ; let numerator = 0 , hcf = 0 ; for ( k = 2 ; k <= n ; k ++ ) { numerator = parseInt ( ( Math . pow ( k , n - 2 ) - k ) ) ; hcf = __gcd ( n , k ) ; } if ( hcf == 1 && ( numerator % n ) != 0 ) return false ; return true ; } function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } let n = 15 ; let a = isDNum ( n ) ; if ( a ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: k
Iterator variables: k