dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function count_setbit ( N ) { let result = 0 ; for ( let i = 0 ; i < 32 ; i ++ ) { if ( ( ( 1 << i ) & N ) > 0 ) { result ++ ; } } document . write ( result ) ; } let N = 43 ; count_setbit ( N ) ;

Accumulator variables: i, result
Iterator variables: i
Javascript program:
let mod = 1000000007 ; function ValOfTheExpression ( n ) { let factorial = new Array ( n + 1 ) ; factorial [ 0 ] = factorial [ 1 ] = 1 ; for ( let i = 2 ; i <= n ; i ++ ) { factorial [ i ] = ( ( factorial [ i - 1 ] % mod ) * ( i % mod ) ) % mod ; } let dp = new Array ( n + 1 ) ; dp [ 1 ] = 1 ; for ( let i = 2 ; i <= n ; i ++ ) { dp [ i ] = ( ( dp [ i - 1 ] % mod ) * ( factorial [ i ] % mod ) ) % mod ; } return dp [ n ] ; } let n = 4 ; document . write ( ValOfTheExpression ( n ) ) ;

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Javascript program:
function minChocolates ( A , N ) { let B = new Array ( N ) . fill ( 0 ) ; for ( let i = 0 ; i < N ; i ++ ) { B [ i ] = 1 ; } for ( let i = 1 ; i < N ; i ++ ) { if ( A [ i ] > A [ i - 1 ] ) B [ i ] = B [ i - 1 ] + 1 ; else B [ i ] = 1 ; } for ( let i = N - 2 ; i >= 0 ; i -- ) { if ( A [ i ] > A [ i + 1 ] ) B [ i ] = Math . max ( B [ i + 1 ] + 1 , B [ i ] ) ; else B [ i ] = Math . max ( B [ i ] , 1 ) ; } let sum = 0 ; for ( let i = 0 ; i < N ; i ++ ) { sum += B [ i ] ; } document . write ( sum + " " ) ; } let A = [ 23 , 14 , 15 , 14 , 56 , 29 , 14 ] ; let N = A . length ; minChocolates ( A , N ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function constructArrayWithGivenLCM ( N ) { let newArr = new Array ( N ) ; newArr . fill ( 0 ) ; let j = 0 ; for ( let i = 1 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { newArr [ j ] = i ; j ++ ; if ( parseInt ( N / i , 10 ) != i ) { newArr [ j ] = parseInt ( N / i , 10 ) ; j ++ ; } } } newArr . sort ( function ( a , b ) { return a - b } ) ; for ( let i = j ; i < N ; i ++ ) { document . write ( newArr [ i ] + " " ) ; } } let N = 12 ; constructArrayWithGivenLCM ( N ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Javascript program:
function getPower ( p ) { var res = 1 ; while ( p -- ) { res *= 5 ; } return res ; } function countNumbersUtil ( N ) { var count = 0 ; var digits = [ ] ; while ( N ) { digits . push ( N % 10 ) ; N = parseInt ( N / 10 ) ; } digits . reverse ( ) ; var D = digits . length ; for ( var i = 1 ; i <= D ; i ++ ) { var res = getPower ( i ) ; if ( i == D ) { for ( var p = 1 ; p <= D ; p ++ ) { var x = digits [ p - 1 ] ; var tmp = 0 ; if ( p % 2 == 0 ) { tmp = ( 5 - parseInt ( x / ( 2 + 1 ) ) ) * getPower ( D - p ) ; } else { tmp = ( 5 - parseInt ( ( x + 1 ) / 2 ) ) * getPower ( D - p ) ; } res -= tmp ; if ( p % 2 != x % 2 ) { break ; } } } count += res ; } return count ; } function countNumbers ( L , R ) { document . write ( ( countNumbersUtil ( R ) - countNumbersUtil ( L - 1 ) ) + " " ) ; } var L = 128 , R = 162 ; countNumbers ( L , R ) ;

Accumulator variables: count, i, p, res
Iterator variables: i, p
Javascript program:
function alternatingSumOfFirst_N ( N ) { var alternateSum = 0 ; for ( i = 1 ; i <= N ; i ++ ) { if ( i % 2 == 0 ) { alternateSum += - i ; } else { alternateSum += i ; } } return alternateSum ; } var N = 6 ; document . write ( alternatingSumOfFirst_N ( N ) ) ;

Accumulator variables: alternateSum, i
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function findSum ( N ) { var sum = 0 ; for ( var i = 1 ; i < N ; i ++ ) { if ( gcd ( i , N ) == 1 ) { sum += i ; } } return sum ; } var N = 5 ; document . write ( findSum ( N ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function solve ( arr , n ) { var mp = new Map ( ) ; for ( var i = 0 ; i < n ; i ++ ) { if ( mp . has ( arr [ i ] ) ) mp . set ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) else mp . set ( arr [ i ] , 1 ) ; } var cnt = 0 ; mp . forEach ( ( value , key ) => { cnt += ( ( value ) * ( value - 1 ) / 2 ) ; } ) ; var ans = Array ( n ) ; for ( var i = 0 ; i < n ; i ++ ) { ans [ i ] = cnt - ( mp . get ( arr [ i ] ) - 1 ) ; } for ( var i = 0 ; i < n ; i ++ ) { document . write ( ans [ i ] + " " ) ; } } var arr = [ 1 , 1 , 2 , 1 , 2 ] ; var N = arr . length ; solve ( arr , N ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function modexp ( x , n , m ) { if ( n == 0 ) { return 1 ; } else if ( n % 2 == 0 ) { return modexp ( ( x * x ) % m , parseInt ( n / 2 , 10 ) , m ) ; } else { return ( x * modexp ( ( x * x ) % m , parseInt ( ( n - 1 ) / 2 , 10 ) , m ) % m ) ; } } function modInverse ( x , m ) { return modexp ( x , m - 2 , m ) ; } function countNumbers ( N ) { let m = 1000000007 ; let factorial = new Array ( 100001 ) ; factorial [ 0 ] = 1 ; for ( let i = 1 ; i < 100001 ; i ++ ) { factorial [ i ] = ( factorial [ i - 1 ] * i ) % m ; } let count = new Array ( 10 ) ; for ( let i = 0 ; i < 10 ; i ++ ) { count [ i ] = 0 ; } let length = N . length ; for ( let i = 0 ; i < length ; i ++ ) count [ N [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; let result = factorial [ length ] ; for ( let i = 0 ; i < 10 ; i ++ ) { result = 0 * ( result * modInverse ( factorial [ count [ i ] ] , m ) ) % m + 12 ; } document . write ( result ) ; } let N = " " ; countNumbers ( N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var spf = Array ( 10001 ) ; function spf_array ( spf ) { spf [ 1 ] = 1 ; for ( var i = 2 ; i < 1000 ; i ++ ) spf [ i ] = i ; for ( var i = 4 ; i < 1000 ; i += 2 ) spf [ i ] = 2 ; for ( var i = 3 ; i * i < 1000 ; i ++ ) { if ( spf [ i ] == i ) { for ( var j = i * i ; j < 1000 ; j += i ) if ( spf [ j ] == j ) spf [ j ] = i ; } } } function frequent_prime ( arr , N , K ) { spf_array ( spf ) ; var Hmap = new Map ( ) ; var result = [ ] ; var i = 0 ; var c = 0 ; for ( i = 0 ; i < N ; i ++ ) { var x = arr [ i ] ; while ( x != 1 ) { if ( Hmap . has ( spf [ x ] ) ) Hmap . set ( spf [ x ] , Hmap . get ( spf [ x ] ) + 1 ) else Hmap . set ( spf [ x ] , 1 ) ; x = parseInt ( x / spf [ x ] ) ; } } Hmap . delete ( 1 ) ; Hmap . forEach ( ( value , key ) => { var primeNum = key ; var frequency = value ; if ( frequency % K == 0 ) { result . push ( primeNum ) ; } } ) ; if ( result . length > 0 ) { result . forEach ( it => { document . write ( it + " " ) ; } ) ; } else { document . write ( " " ) ; } } var arr = [ 1 , 4 , 6 ] ; var K = 1 ; var N = arr . length ; frequent_prime ( arr , N , K ) ;

Index/key variables: i, j, x
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function Kmultiples ( n , k ) { var a = n ; for ( i = 1 ; i <= k ; i ++ ) { document . write ( n + " " + i + " " + a + " " ) ; var j = 0 ; while ( n >= ( 1 << j ) ) { a += n & ( 1 << j ) ; j ++ ; } } } var N = 16 , K = 7 ; Kmultiples ( N , K ) ;

Accumulator variables: a, i, j
Iterator variables: i
Javascript program:
function calculateB ( x , y ) { let n = x . length ; let sx = x . reduce ( ( a , b ) => a + b , 0 ) ; let sy = y . reduce ( ( a , b ) => a + b , 0 ) let sxsy = 0 ; let sx2 = 0 ; for ( let i = 0 ; i < n ; i ++ ) { sxsy += x [ i ] * y [ i ] ; sx2 += x [ i ] * x [ i ] ; } let b = ( n * sxsy - sx * sy ) / ( n * sx2 - sx * sx ) ; return b ; } function leastRegLine ( X , Y ) { let b = calculateB ( X , Y ) ; let n = X . length ; let meanX = X . reduce ( ( a , b ) => a + b , 0 ) / n ; let meanY = Y . reduce ( ( a , b ) => a + b , 0 ) / n ; let a = meanY - b * meanX ; document . write ( " " ) ; document . write ( " " ) ; document . write ( a . toFixed ( 3 ) ) ; document . write ( " " ) ; document . write ( b . toFixed ( 3 ) ) ; document . write ( " " ) ; } let X = [ 95 , 85 , 80 , 70 , 60 ] ; let Y = [ 90 , 80 , 70 , 65 , 60 ] ; leastRegLine ( X , Y ) ;

Index/key variables: i
Accumulator variables: i, sx2, sxsy
Iterator variables: i
Javascript program:
function countRepeatingDigits ( N ) { var res = 0 ; var cnt = Array ( 10 ) . fill ( 0 ) ; while ( N > 0 ) { var rem = N % 10 ; cnt [ rem ] ++ ; N = N / 10 ; } for ( var i = 0 ; i < 10 ; i ++ ) { if ( cnt [ i ] > 1 ) { res ++ ; } } return res ; } var N = 12 ; document . write ( countRepeatingDigits ( N ) ) ;

Index/key variables: i, rem
Accumulator variables: i, res
Iterator variables: i
Javascript program:
function freqCount ( str , k ) { var count = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] == k ) count ++ ; } return count ; } function findAandB ( n , k ) { var flag = 0 ; for ( var i = 1 ; i < n ; i ++ ) { if ( freqCount ( i . toString ( ) , String . fromCharCode ( k + 48 ) ) == 0 && freqCount ( ( n - i ) . toString ( ) , String . fromCharCode ( k + 48 ) ) == 0 ) { document . write ( " " + i + " " + ( n - i ) + " " ) ; flag = 1 ; break ; } } if ( flag == 0 ) cout + - 1 ; } var N = 100 ; var K = 0 ; findAandB ( N , K ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function MaxSubarrayLength ( arr , n , k ) { let left = - 1 ; let right = 0 ; let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] % k ) != 0 ) { if ( left == - 1 ) { left = i ; } right = i ; } sum += arr [ i ] ; } if ( ( sum % k ) != 0 ) { return n ; } else if ( left == - 1 ) { return - 1 ; } else { let prefix_length = left + 1 ; let suffix_length = n - right ; return n - Math . min ( prefix_length , suffix_length ) ; } } let arr = [ 6 , 3 , 12 , 15 ] ; let n = arr . length ; let K = 3 ; document . write ( MaxSubarrayLength ( arr , n , K ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function countQuadraples ( N ) { var cnt = 0 ; var m = new Map ( ) ; for ( var a = 1 ; a <= N ; a ++ ) { for ( var b = 1 ; b <= N ; b ++ ) { var x = a * a + b * b ; if ( m . has ( x ) ) m . set ( x , m . get ( x ) + 1 ) else m . set ( x , 1 ) } } for ( var c = 1 ; c <= N ; c ++ ) { for ( var d = 1 ; d <= N ; d ++ ) { var x = c * c + d * d ; if ( m . has ( x ) ) cnt += m . get ( x ) ; } } return cnt ; } var N = 2 ; document . write ( countQuadraples ( N ) )

Accumulator variables: a, b, c, cnt, d
Iterator variables: a, b, c, d
Javascript program:
function count_pairs ( a , b , N ) { let i , j ; let count = 0 ; for ( i = 0 ; i < ( N - 1 ) ; i ++ ) { for ( j = ( i + 1 ) ; j < N ; j ++ ) { if ( ( a [ i ] + a [ j ] ) > ( b [ i ] + b [ j ] ) ) { count ++ ; } } } return count ; } let N = 5 ; let a = [ 1 , 2 , 3 , 4 , 5 ] ; let b = [ 2 , 5 , 6 , 1 , 9 ] ; document . write ( count_pairs ( a , b , N ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function numberOfPairs ( a , b , n ) { let c = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { c [ i ] = a [ i ] - b [ i ] ; } c . sort ( function ( a , b ) { return a - b } ) ; let answer = 0 ; for ( let i = 1 ; i < n ; i ++ ) { if ( c [ i ] <= 0 ) continue ; let pos = - 1 ; for ( let j = 0 ; j < n ; j ++ ) { if ( c [ i ] + c [ j ] > 0 ) { pos = j ; break ; } } answer += ( i - pos ) ; } return answer ; } let n = 5 ; let a = [ 1 , 2 , 3 , 4 , 5 ] ; let b = [ 2 , 5 , 6 , 1 , 9 ] ; document . write ( numberOfPairs ( a , b , n ) ) ;

Index/key variables: i, j
Accumulator variables: answer, i, j
Iterator variables: i, j
Javascript program:
function print_h_index ( arr , N ) { var ms = [ ] ; for ( var i = 0 ; i < N ; i ++ ) { ms . push ( arr [ i ] ) ; ms . sort ( ( a , b ) => a - b ) if ( ms [ 0 ] < ms . length ) { ms . shift ( ) ; } document . write ( ms . length + " " ) ; } } var arr = [ 9 , 10 , 7 , 5 , 0 , 10 , 2 , 0 ] ; var N = arr . length ; print_h_index ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function prefixProduct ( a , n ) { for ( let i = 1 ; i < n ; i ++ ) { a [ i ] = a [ i ] * a [ i - 1 ] ; } for ( let j = 0 ; j < n ; j ++ ) { document . write ( a [ j ] + " " ) ; } return 0 ; } let arr = [ 2 , 4 , 6 , 5 , 10 ] ; let N = arr . length ; prefixProduct ( arr , N ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function countWays ( N ) { if ( N < 4 ) return 0 ; let ans = ( ( N - 1 ) * ( N - 2 ) ) / 2 ; let s = 0 ; for ( let i = 2 ; i <= N - 3 ; i ++ ) { for ( let j = 1 ; j < i ; j ++ ) { if ( N == 2 * i + j ) s ++ ; } } if ( N % 3 == 0 ) s = 3 * s + 1 ; else s = 3 * s ; return ans - s ; } let N = 10 ; document . write ( countWays ( N ) ) ;

Accumulator variables: i, j, s
Iterator variables: i, j
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 isMagnanimous ( N ) { let s = N . toString ( ) ; let l = s . length ; if ( l < 2 ) return false ; for ( let i = 0 ; i < l - 1 ; i ++ ) { let left = s . substring ( 0 , i + 1 ) ; let right = s . substring ( i + 1 ) ; let x = parseInt ( left ) ; let y = parseInt ( right ) ; if ( ! isPrime ( x + y ) ) return false ; } return true ; } let N = 12 ; if ( isMagnanimous ( N ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
const limit = 10000000 ; let position = Array ( limit + 1 ) . fill ( 0 ) ; function sieve ( ) { position [ 0 ] = - 1 ; position [ 1 ] = - 1 ; let pos = 0 ; for ( let i = 2 ; i <= limit ; i ++ ) { if ( position [ i ] == 0 ) { position [ i ] = ++ pos ; for ( let j = i * 2 ; j <= limit ; j += i ) position [ j ] = - 1 ; } } } function getSum ( n ) { let sum = 0 ; while ( n != 0 ) { sum = sum + n % 10 ; n = parseInt ( n / 10 ) ; } return sum ; } function isHonakerPrime ( n ) { let pos = position [ n ] ; if ( pos == - 1 ) return false ; return getSum ( n ) == getSum ( pos ) ; } sieve ( ) ; let N = 121 ; if ( isHonakerPrime ( N ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let N = 4 , M = 5 ; function isPrime ( n ) { if ( n <= 1 ) return false ; for ( let i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) if ( n % i == 0 ) return false ; return true ; } function takeSum ( a ) { let s = 0 ; for ( let i = 0 ; i < N ; i ++ ) for ( let j = 0 ; j < M ; j ++ ) s += a [ i ] [ j ] ; return s ; } let a = [ [ 1 , 2 , 3 , 4 , 2 ] , [ 0 , 1 , 2 , 3 , 34 ] , [ 0 , 34 , 21 , 12 , 12 ] , [ 1 , 2 , 3 , 6 , 6 ] ] ; let sum = takeSum ( a ) ; if ( isPrime ( sum ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j, s
Iterator variables: i, j
Javascript program:
function sumOfSumSeries ( N ) { let sum = 0 ; for ( let i = 1 ; i <= N ; i ++ ) { sum = sum + ( i * ( i + 1 ) ) / 2 ; } return sum ; } let N = 5 ; document . write ( sumOfSumSeries ( N ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function isContaindigit ( n ) { while ( n > 0 ) { if ( ! ( n % 10 == 0 n % 10 == 1 n % 10 == 8 ) ) return false ; n = parseInt ( n / 10 , 10 ) ; } return true ; } function ispalindrome ( n ) { let temp = n . toString ( ) ; let l = temp . length ; for ( let i = 0 ; i < parseInt ( l / 2 , 10 ) ; i ++ ) { if ( temp [ i ] != temp [ l - i - 1 ] ) return false ; } return true ; } function isTetradic ( n ) { if ( ispalindrome ( n ) && isContaindigit ( n ) ) return true ; return false ; } function printTetradicPrimesLessThanN ( n ) { let prime = new Array ( n + 1 ) ; prime . fill ( true ) ; let p = 2 ; while ( p * p <= n ) { if ( prime [ p ] ) { for ( let i = p * 2 ; i < n + 1 ; i += p ) prime [ i ] = false ; } p += 1 ; } for ( p = 2 ; p < n + 1 ; p ++ ) { if ( prime [ p ] && isTetradic ( p ) ) document . write ( p + " " ) ; } } let n = 1000 ; printTetradicPrimesLessThanN ( n ) ;

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Javascript program:
function concat ( a , b ) { var s1 = a . toString ( ) ; var s2 = b . toString ( ) ; var s = s1 + s2 ; var c = s ; return c ; } function isAstonishing ( n ) { for ( var i = 1 ; i < n ; i ++ ) { var sum = 0 ; for ( var j = i ; j < n ; j ++ ) { sum += j ; if ( sum == n ) { var concatenation = concat ( i , j ) ; if ( concatenation == n ) { return true ; } } } } return false ; } var n = 429 ; if ( isAstonishing ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i, j, sum
Iterator variables: i, j
Javascript program:
function checkSame ( n , b ) { var m = { } ; while ( n != 0 ) { var r = n % b ; n = n / b ; if ( r in m ) m [ r ] += 1 else m [ r ] = 1 } var last = - 1 ; for ( var i in m ) { if ( last != - 1 && m [ i ] != last ) { return false ; } else { last = m [ i ] ; } } return true ; } var n = 9 ; var base = 2 ; if ( checkSame ( n , base ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, r
Iterator variables: i
Javascript program:
function seriesSum ( n ) { let sum = 0 ; let currProd = 1 ; let currSum = 1 ; for ( let i = 2 ; i <= n ; i ++ ) { currProd *= i ; currSum += i ; sum += currProd - currSum ; } return sum ; } let N = 5 ; document . write ( seriesSum ( N ) + " " ) ;

Accumulator variables: currProd, currSum, i, sum
Iterator variables: i
Javascript program:
function count ( a , n ) { let countElements = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let flag = true ; for ( let j = 0 ; j < n ; j ++ ) { if ( i == j ) continue ; if ( a [ i ] % a [ j ] == 0 ) { flag = false ; break ; } } if ( flag == true ) ++ countElements ; } return countElements ; } let arr = [ 86 , 45 , 18 , 4 , 8 , 28 , 19 , 33 , 2 ] ; let n = arr . length ; document . write ( count ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: flag
Javascript program:
function CountPairs ( arr , n ) { let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { if ( arr [ i ] % 2 == 0 arr [ j ] % 2 == 0 ) count ++ ; } } return count ; } let arr = [ 8 , 2 , 3 , 1 , 4 , 2 ] ; let n = arr . length ; document . write ( CountPairs ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function CountPairs ( arr , n ) { let even = 0 , odd = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) even ++ ; else odd ++ ; } return ( even * ( even - 1 ) ) / 2 + ( even * odd ) ; } let arr = [ 8 , 2 , 3 , 1 , 4 , 2 ] ; let n = arr . length ; document . write ( CountPairs ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Javascript program:
function isComposite ( n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return false ; if ( n % 2 == 0 n % 3 == 0 ) return true ; for ( let i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } function isGiugaNum ( n ) { if ( ! ( isComposite ( n ) ) ) return false ; let N = n ; while ( n % 2 == 0 ) { if ( ( N / 2 - 1 ) % 2 != 0 ) return false ; n = n / 2 ; } for ( let i = 3 ; i <= Math . sqrt ( n ) ; i = i + 2 ) { while ( n % i == 0 ) { if ( ( N / i - 1 ) % i != 0 ) return false ; n = n / i ; } } if ( n > 2 ) if ( ( N / n - 1 ) % n != 0 ) return false ; return true ; } let n = 30 ; if ( isGiugaNum ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Iterator variables: i
Javascript program:
function isDroll ( n ) { if ( n == 1 ) return false ; let sum_even = 0 ; let sum_odd = 0 ; while ( n % 2 == 0 ) { sum_even += 2 ; n = n / 2 ; } for ( let i = 3 ; i <= Math . sqrt ( n ) ; i = i + 2 ) { while ( n % i == 0 ) { sum_odd += i ; n = n / i ; } } if ( n > 2 ) sum_odd += n ; return sum_even == sum_odd ; } let n = 72 ; if ( isDroll ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: sum_even, sum_odd
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( b == 0 ) return a ; return ( gcd ( b , a % b ) ) ; } function CountPairs ( n ) { let cnt = 0 ; for ( let i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { let div1 = i ; let div2 = Math . floor ( n / i ) ; let sum = div1 + div2 ; if ( gcd ( sum , n ) == 1 ) cnt += 1 ; } } return cnt ; } let n = 24 ; document . write ( CountPairs ( n ) + " " ) ;

Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
let sub = new Array ( 100005 ) ; sub . fill ( 0 ) ; function minDivisorDifference ( n ) { let num1 = 0 ; let num2 = 0 ; for ( let i = parseInt ( Math . sqrt ( n ) , 10 ) ; i <= n ; i ++ ) { if ( n % i == 0 ) { num1 = i ; num2 = parseInt ( n / i , 10 ) ; break ; } } return Math . abs ( num1 - num2 ) ; } function dfs ( g , u , par ) { sub [ u ] = minDivisorDifference ( u ) ; let mx = 0 ; for ( let c = 0 ; c < g [ u ] . length ; c ++ ) { if ( g [ u ] != par ) { let ans = dfs ( g , g [ u ] , u ) ; mx = Math . max ( mx , ans ) ; } } sub [ u ] += mx ; return sub [ u ] ; } let g = new Array ( 100005 ) ; for ( let i = 0 ; i < g . length ; i ++ ) g [ i ] = [ ] ; let edges = 6 ; g [ 18 ] . push ( 7 ) ; g [ 7 ] . push ( 18 ) ; g [ 18 ] . push ( 15 ) ; g [ 15 ] . push ( 18 ) ; g [ 15 ] . push ( 2 ) ; g [ 2 ] . push ( 15 ) ; g [ 7 ] . push ( 4 ) ; g [ 4 ] . push ( 7 ) ; g [ 7 ] . push ( 12 ) ; g [ 12 ] . push ( 7 ) ; g [ 12 ] . push ( 9 ) ; g [ 9 ] . push ( 12 ) ; let root = 18 ; document . write ( dfs ( g , root , - 1 ) ) ;

Index/key variables: i, u
Accumulator variables: c, i
Iterator variables: c, i
Javascript program:
function isCenteredcube ( N ) { let i = 1 ; while ( true ) { let ith_term = ( 2 * i + 1 ) * ( i * i + i + 1 ) ; if ( ith_term == N ) { return true ; } if ( ith_term > N ) { return false ; } i ++ ; } } let N = 9 ; if ( isCenteredcube ( N ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Accumulator variables: i
Javascript program:
function productOfGP ( a , r , n ) { let product = 1 ; for ( let i = 0 ; i < n ; i ++ ) { product = product * a ; a = a * r ; } return product ; } let a = 1 , r = 2 ; let N = 4 ; document . write ( productOfGP ( a , r , N ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ) ; } function findlcm ( arr , n ) { var ans = arr [ 0 ] ; for ( var i = 1 ; i < n ; i ++ ) { ans = ( ( ( arr [ i ] * ans ) ) / ( gcd ( arr [ i ] , ans ) ) ) ; } return ans ; } function addReduce ( n , num , den ) { var final_numerator = 0 ; var final_denominator = findlcm ( den , n ) ; for ( var i = 0 ; i < n ; i ++ ) { final_numerator = final_numerator + ( num [ i ] ) * parseInt ( final_denominator / den [ i ] ) ; } var GCD = gcd ( final_numerator , final_denominator ) ; final_numerator = parseInt ( final_numerator / GCD ) ; final_denominator = parseInt ( final_denominator / GCD ) ; document . write ( final_numerator + " " + final_denominator + " " ) ; } var N = 3 ; var arr1 = [ 1 , 2 , 5 ] ; var arr2 = [ 2 , 1 , 6 ] ; addReduce ( N , arr1 , arr2 ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } function minLCM ( arr , n ) { let ans = Number . MAX_VALUE ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { let g = gcd ( arr [ i ] , arr [ j ] ) ; let lcm = arr [ i ] / g * arr [ j ] ; ans = Math . min ( ans , lcm ) ; } } return ans ; } let arr = [ 2 , 4 , 3 , 6 , 5 ] ; let n = arr . length ; document . write ( minLCM ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function solve ( n ) { let upper_limit = Math . ceil ( Math . pow ( n , 1.0 / 4 ) ) ; for ( let x = 0 ; x <= upper_limit ; x ++ ) { for ( let y = 0 ; y <= upper_limit ; y ++ ) { let num1 = x * x * x * x ; let num2 = y * y * y * y ; if ( num1 - num2 == n ) { document . write ( " " + x + " " + y ) ; return ; } } } document . write ( - 1 ) ; } let n = 15 ; solve ( n ) ;

Accumulator variables: x, y
Iterator variables: x, y