dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function checkSpecialPrime ( sieve , num ) { while ( num != 0 ) { if ( ! sieve [ num ] ) { return false ; } num = Math . floor ( num / 10 ) ; } return true ; } function findSpecialPrime ( N ) { let sieve = new Array ( N + 10 ) ; sieve [ 0 ] = sieve [ 1 ] = false ; for ( let i = 0 ; i < N + 10 ; i ++ ) sieve [ i ] = true ; for ( let i = 2 ; i <= N ; i ++ ) { if ( sieve [ i ] ) { for ( let j = i * i ; j <= N ; j += i ) { sieve [ j ] = false ; } } } while ( true ) { if ( checkSpecialPrime ( sieve , N ) ) { document . write ( N + " " ) ; break ; } else N -- ; } } findSpecialPrime ( 379 ) ; findSpecialPrime ( 100 ) ;

Index/key variables: i, j, num
Accumulator variables: N, i, j
Iterator variables: i, j
Javascript program:
var MAX = 1000000 ; var arr = [ ] ; var sprime = Array ( MAX ) . fill ( false ) ; function computeSemiPrime ( ) { for ( var i = 2 ; i < MAX ; i ++ ) { var cnt = 0 ; var num = i ; for ( var j = 2 ; cnt < 2 && j * j <= num ; ++ j ) { while ( num % j == 0 ) { } } if ( num > 1 ) ++ cnt ; if ( cnt == 2 ) { sprime [ i ] = true ; arr . push ( i ) ; } } } function checkSemiPrime ( n ) { var i = 0 ; while ( arr [ i ] <= parseInt ( n / 2 ) ) { if ( sprime [ n - arr [ i ] ] ) { return true ; } i ++ ; } return false ; } computeSemiPrime ( ) ; var n = 30 ; if ( checkSemiPrime ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i, j
Javascript program:
function isprime ( x ) { for ( var i = 2 ; i * i <= x ; i ++ ) if ( x % i == 0 ) return false ; return true ; } function isNSqMinusnMSqPrime ( m , n ) { if ( n - m == 1 && isprime ( m + n ) ) return true ; else return false ; } var m = 13 , n = 16 ; if ( isNSqMinusnMSqPrime ( m , n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function findsolution ( n , x , y ) { if ( ( y - n + 1 ) * ( y - n + 1 ) + n - 1 < x y < n ) { document . write ( " " ) ; return ; } document . write ( y - n + 1 ) ; while ( n -- > 1 ) document . write ( " " + 1 ) ; } let n = 5 ; let x = 15 ; let y = 15 ; findsolution ( n , x , y ) ;

Accumulator variables: n
Javascript program:
function checkIfPowerIsolated ( num ) { let input = num ; let count = 0 ; let factor = new Array ( 0 ) ; if ( num % 2 == 0 ) { while ( num % 2 == 0 ) { ++ count ; num /= 2 ; } factor [ 2 ] = count ; } for ( let i = 3 ; i * i <= num ; i += 2 ) { count = 0 ; while ( num % i == 0 ) { ++ count ; num /= i ; } if ( count > 0 ) factor [ i ] = count ; } if ( num > 1 ) factor [ num ] = 1 ; let product = 1 ; for ( let i = 0 ; i < num + 1 ; i ++ ) { if ( factor [ i ] > 0 ) product = product * factor [ i ] * i ; } if ( product == input ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ; } checkIfPowerIsolated ( 12 ) ; checkIfPowerIsolated ( 18 ) ; checkIfPowerIsolated ( 35 ) ;

Index/key variables: i, num
Accumulator variables: i, num
Iterator variables: i
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 factors ( N , v ) { for ( let i = 2 ; i < N ; i ++ ) { for ( let j = 1 ; j * j <= i ; j ++ ) { if ( i % j == 0 ) { if ( i / j == j ) v [ i ] . push ( j ) ; else { v [ i ] . push ( j ) ; v [ i ] . push ( i / j ) ; } } } v . sort ( ( a , b ) => a - b ) ; } } function product ( n ) { let v = new Array ( ) ; for ( let i = 0 ; i < n + 100 ; i ++ ) { v . push ( new Array ( ) ) } factors ( n + 100 , v ) ; if ( n % 4 == 0 ) { let x = n / 4 ; x *= x ; return x * x ; } else { if ( isPrime [ n ] ) return - 1 ; else { let ans = - 1 ; if ( v [ n ] . length > 2 ) { let fac = v [ n ] [ v [ n ] . length - 3 ] ; for ( let i = v [ n ] . length - 1 ; i >= 0 ; i -- ) { for ( let j = v [ n ] . length - 1 ; j >= 0 ; j -- ) { if ( ( fac * 2 ) + ( v [ n ] [ j ] + v [ n ] [ i ] ) == n ) ans = Math . max ( ans , fac * fac * v [ n ] [ j ] * v [ n ] [ i ] ) ; } } return ans ; } } } } let n = 24 ; document . write ( product ( n ) ) ;

Index/key variables: i, j, n
Accumulator variables: i, j, x
Iterator variables: i, j
Javascript program:
function digSum ( n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } function powerDigitSum ( a , n ) { let res = 1 ; while ( n ) { if ( n % 2 == 1 ) { res = res * digSum ( a ) ; res = digSum ( res ) ; } a = digSum ( digSum ( a ) * digSum ( a ) ) ; n /= 2 ; } return res ; } let a = 9 , n = 4 ; document . write ( powerDigitSum ( a , n ) ) ;

Accumulator variables: n
Javascript program:
MAX = 1000005 var prime = Array ( MAX ) . fill ( true ) ; function sieve ( N ) { prime [ 0 ] = prime [ 1 ] = false ; for ( var i = 2 ; i <= N ; i ++ ) { if ( prime [ i ] ) { for ( var j = 2 ; i * j <= N ; j ++ ) prime [ i * j ] = false ; } } } function countLogNeeded ( N ) { var count = 0 ; sieve ( N ) ; for ( var i = 1 ; i <= N ; i ++ ) { if ( prime [ i ] ) count ++ ; } return count ; } var N = 6 ; document . write ( countLogNeeded ( N ) ) ;

Index/key variables: i
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function findfactors ( n ) { let mpp = new Map ( ) ; let v = [ ] ; let v1 = [ ] ; for ( let i = 1 ; i <= Math . floor ( Math . sqrt ( n ) ) ; i ++ ) { if ( n % i == 0 ) { v . push ( i ) ; if ( i != Math . floor ( n / i ) && i != 1 ) v . push ( Math . floor ( n / i ) ) ; } } let s = v . length ; let maxi = - 1 ; let mp1_first = new Array ( n + 5 ) , mp1_second = new Array ( n + 5 ) ; for ( let i = 0 ; i < s ; i ++ ) { for ( let j = i ; j < s ; j ++ ) { if ( v [ i ] + v [ j ] < n ) { v1 . push ( v [ i ] + v [ j ] ) ; mp1_first [ v [ i ] + v [ j ] ] = v [ i ] ; mp1_second [ v [ i ] + v [ j ] ] = v [ j ] ; mpp . set ( v [ i ] + v [ j ] , 1 ) ; } } } s = v1 . length ; for ( let i = 0 ; i < s ; i ++ ) { let el = n - ( v1 [ i ] ) ; if ( mpp . get ( el ) != null ) { let a = mp1_first [ v1 [ i ] ] ; let b = mp1_second [ v1 [ i ] ] ; let c = mp1_first [ n - v1 [ i ] ] ; let d = mp1_second [ n - v1 [ i ] ] ; maxi = Math . max ( a * b * c * d , maxi ) ; } } if ( maxi == - 1 ) document . write ( " " ) ; else { document . write ( " " + " " + maxi ) ; } } let n = 50 ; findfactors ( n ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let factors = [ ] ; function findFactors ( n ) { for ( let i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { if ( ( n / i ) == i ) { factors . push ( i ) ; } else { factors . push ( n / i ) ; factors . push ( i ) ; } } } } function findProduct ( n ) { let product = - 1 ; let si = factors . length ; for ( let i = 0 ; i < si ; i ++ ) { for ( let j = 0 ; j < si ; j ++ ) { for ( let k = 0 ; k < si ; k ++ ) { for ( let l = 0 ; l < si ; l ++ ) { let s = factors [ i ] + factors [ j ] + factors [ k ] + factors [ l ] ; if ( s == n ) { let p = factors [ i ] * factors [ j ] * factors [ k ] * factors [ l ] ; if ( p > product ) { product = p ; } } } } } } return product ; } let n = 10 ; findFactors ( n ) ; document . write ( findProduct ( n ) ) ;

Index/key variables: i, j, k, l
Accumulator variables: i, j, k, l
Iterator variables: i, j, k, l
Javascript program:
function isDivisible ( n ) { while ( Math . floor ( n / 100 ) > 0 ) { let d = n % 10 ; n = Math . floor ( n / 10 ) ; n -= d * 5 ; } return ( n % 17 == 0 ) ; } let n = 19877658 ; if ( isDivisible ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: n
Javascript program:
function nextPowerOf2 ( n ) { let count = 0 ; if ( n && ! ( n & ( n - 1 ) ) ) return n ; while ( n != 0 ) { n >>= 1 ; count += 1 ; } return 1 << count ; } function removeElement ( n ) { if ( n == 1 n == 2 ) return 0 ; let a = nextPowerOf2 ( n ) ; if ( n == a n == a - 1 ) return 1 ; else if ( n == a - 2 ) return 0 ; else if ( n % 2 == 0 ) return 1 ; else return 2 ; } let n = 5 ; document . write ( removeElement ( n ) ) ;

Accumulator variables: count
Javascript program:
var MOD = 100000007 ; function modInv ( x ) { var n = MOD - 2 ; var result = 1 ; while ( n ) { if ( n & 1 ) result = result * x % MOD ; x = x * x % MOD ; n = n / 2 ; } return result ; } function getSum ( n , k ) { var ans = 1 ; for ( var i = n + 1 ; i > n - k ; i -- ) ans = ans * i % MOD ; ans = ans * modInv ( k + 1 ) % MOD ; return ans ; } var n = 3 , k = 2 ; document . write ( getSum ( n , k ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
var target = 93 ; var arr = [ 1 , 31 , 3 , 1 , 93 , 3 , 31 , 1 , 93 ] ; var length = arr . length ; var totalCount = 0 ; for ( var i = 0 ; i < length - 2 ; i ++ ) { if ( target % arr [ i ] == 0 ) { for ( var j = i + 1 ; j < length - 1 ; j ++ ) { if ( target % ( arr [ i ] * arr [ j ] ) == 0 ) { var toFind = target / ( arr [ i ] * arr [ j ] ) ; for ( var k = j + 1 ; k < length ; k ++ ) { if ( arr [ k ] == toFind ) { totalCount ++ ; } } } } } } document . write ( " " + totalCount ) ;

Index/key variables: i, j, k
Accumulator variables: i, j, k, totalCount
Iterator variables: i, j, k
Javascript program:
function binomialCoeff ( n , k ) { var res = 1 ; if ( k > n - k ) k = n - k ; for ( var i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } function catalan ( n ) { var c = binomialCoeff ( 2 * n , n ) ; return c / ( n + 1 ) ; } var n = 3 ; document . write ( catalan ( n ) ) ;

Accumulator variables: res
Iterator variables: i
Javascript program:
function isFascinating ( num ) { let freq = new Array ( 10 ) ; for ( let i = 0 ; i < freq . length ; i ++ ) { freq [ i ] = 0 ; } let val = " " + num + num * 2 + num * 3 ; for ( let i = 0 ; i < val . length ; i ++ ) { let digit = val [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( freq [ digit ] > 0 && digit != 0 ) return false ; else freq [ digit ] ++ ; } for ( let i = 1 ; i < freq . length ; i ++ ) { if ( freq [ i ] == 0 ) return false ; } return true ; } let num = 192 ; if ( num < 100 ) document . write ( " " ) ; else { let ans = isFascinating ( num ) ; if ( ans ) document . write ( " " ) ; else document . write ( " " ) ; }

Index/key variables: digit, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function binomial_coefficient ( n , m ) { let res = 1 ; if ( m > n - m ) m = n - m ; for ( let i = 0 ; i < m ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } function calculate_ways ( m , n ) { if ( m < n ) return 0 ; let ways = binomial_coefficient ( n + m - 1 , n - 1 ) ; return ways ; } let m = 7 , n = 5 ; let result = calculate_ways ( m , n ) ; document . write ( result ) ;

Accumulator variables: res
Iterator variables: i
Javascript program:
let N = 100005 ; let phi = new Array ( N ) ; let S = new Array ( N ) ; for ( let i = 0 ; i < N ; i ++ ) { phi [ i ] = 0 ; S [ i ] = 0 ; } function computeTotient ( ) { for ( let i = 1 ; i < N ; i ++ ) phi [ i ] = i ; for ( let p = 2 ; p < N ; p ++ ) { if ( phi [ p ] == p ) { phi [ p ] = p - 1 ; for ( let i = 2 * p ; i < N ; i += p ) { phi [ i ] = ( phi [ i ] / p ) * ( p - 1 ) ; } } } } function CoPrimes ( ) { computeTotient ( ) ; for ( let i = 1 ; i < N ; i ++ ) S [ i ] = S [ i - 1 ] + phi [ i ] ; } CoPrimes ( ) ; let q = [ 3 , 4 ] ; let n = q . length ; for ( let i = 0 ; i < n ; i ++ ) document . write ( " " + " " + q [ i ] + " " + S [ q [ i ] ] + " " ) ;

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Javascript program:
function binaryToDecimal ( n ) { let num = n ; let dec_value = 0 ; let base = 1 ; let len = num . length ; for ( let i = len - 1 ; i >= 0 ; i -- ) { if ( num [ i ] == ' ' ) dec_value += base ; base = base * 2 ; } return dec_value ; } function numberSequence ( n ) { if ( n == 1 ) return 1 ; let s = " " ; for ( let i = 1 ; i < n ; i ++ ) s += ' ' ; s += ' ' ; for ( let i = 1 ; i <= n ; i ++ ) s += ' ' ; let num = binaryToDecimal ( s ) ; return num ; } let n = 4 ; document . write ( numberSequence ( n ) ) ;

Index/key variables: i
Accumulator variables: dec_value, i, s
Iterator variables: i
Javascript program:
function prime ( num ) { var i , flag = 0 ; for ( i = 2 ; i <= num / 2 ; i ++ ) { if ( num % i == 0 ) { flag = 1 ; break ; } } if ( flag == 0 ) return 1 ; else return 0 ; } function print_alternate_prime ( n ) { var counter = 0 ; for ( num = 2 ; num < n ; num ++ ) { if ( prime ( num ) == 1 ) { if ( counter % 2 == 0 ) document . write ( num + " " ) ; counter ++ ; } } } var n = 15 ; document . write ( " " + " " + " " + n + " " ) ; print_alternate_prime ( n ) ;

Accumulator variables: counter, i, num
Iterator variables: i, num
Javascript program:
function SieveOfEratosthenes ( n ) { let prime = new Array ( n + 1 ) ; for ( let i = 0 ; i < prime . length ; i ++ ) prime [ i ] = true ; for ( let p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( let i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } let flag = true ; for ( let p = 2 ; p <= n ; p ++ ) { if ( prime [ p ] ) { if ( flag ) { document . write ( p + " " ) ; flag = false ; } else { flag = true ; } } } } let n = 15 ; document . write ( " " + " " + " " + n + " " ) ; SieveOfEratosthenes ( n ) ;

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Boolean variables: flag
Javascript program:
function max_profit ( a , b , n , fee ) { var i , j , profit ; var l , r , diff_day = 1 , sum = 0 ; b [ 0 ] = 0 ; b [ 1 ] = diff_day ; for ( i = 1 ; i < n ; i ++ ) { l = 0 ; r = diff_day ; sum = 0 ; for ( j = n - 1 ; j >= i ; j -- ) { profit = ( a [ r ] - a [ l ] ) - fee ; if ( profit > 0 ) { sum = sum + profit ; } l ++ ; r ++ ; } if ( b [ 0 ] < sum ) { b [ 0 ] = sum ; b [ 1 ] = diff_day ; } diff_day ++ ; } return 0 ; } var arr = [ 6 , 1 , 7 , 2 , 8 , 4 ] ; var n = arr . length ; var b = Array ( 2 ) . fill ( 0 ) ; var tranFee = 2 ; max_profit ( arr , b , n , tranFee ) ; document . write ( b [ 0 ] + " " + b [ 1 ] ) ;

Index/key variables: l, r
Accumulator variables: diff_day, i, j, l, r
Iterator variables: i, j
Javascript program:
function binomialCoeff ( x , n , k ) { var sum = 0 , term = 1 ; for ( var i = 1 ; i <= n && sum < k ; ++ i ) { term *= x - i + 1 ; term /= i ; sum += term ; } return sum ; } function minTrials ( n , k ) { var low = 1 , high = k ; while ( low < high ) { var mid = parseInt ( ( low + high ) / 2 ) ; if ( binomialCoeff ( mid , n , k ) < k ) low = mid + 1 ; else high = mid ; } return low ; } document . write ( minTrials ( 2 , 10 ) ) ;

Accumulator variables: sum, term
Iterator variables: i
Javascript program:
function isPrime ( num ) { if ( num < 2 num % 2 == 0 ) return num == 2 ; for ( i = 3 ; i * i <= num ; i += 2 ) if ( num % i == 0 ) return false ; return true ; } function primePalindrome ( N ) { if ( 8 <= N && N <= 11 ) return 11 ; for ( let x = 1 ; x < 100000 ; ++ x ) { let s = String ( x ) ; let r = s . split ( " " ) . reverse ( ) . join ( " " ) ; let y = parseInt ( s + r . substr ( 1 ) ) ; if ( y >= N && isPrime ( y ) == true ) return y ; } return - 1 ; } document . write ( primePalindrome ( 112 ) ) ;

Accumulator variables: i
Iterator variables: i, x
Javascript program:
function getsum ( a ) { let r = 0 , sum = 0 ; while ( a > 0 ) { r = a % 10 ; sum = sum + r ; a = Math . floor ( a / 10 ) ; } return sum ; } function value ( a , b , c ) { let co = 0 , p = 0 ; let no , r = 0 , x = 0 , q = 0 , w = 0 ; let v = [ ] ; for ( let i = 1 ; i < 82 ; i ++ ) { no = Math . pow ( i , a ) ; no = b * no + c ; if ( no > 0 && no < 1000000000 ) { x = getsum ( no ) ; if ( x == i ) { q ++ ; v . push ( no ) ; w ++ ; } } } for ( let i = 0 ; i < v . length ; i ++ ) { document . write ( v [ i ] + " " ) ; } } let a = 2 , b = 2 , c = - 1 ; value ( a , b , c ) ;

Index/key variables: i
Accumulator variables: i, q, w
Iterator variables: i
Javascript program:
function print ( p0 ) { var p1 , i = 0 , x , flag = 1 , k , m = 4 ; while ( flag ) { flag = 1 ; x = Math . pow ( 2 , i ) ; p1 = x * p0 - ( x - 1 ) ; for ( k = 2 ; k < p1 ; k ++ ) { if ( p1 % k == 0 ) { flag = 0 ; break ; } } if ( flag == 0 ) break ; document . write ( p1 + " " ) ; i ++ ; } } var p0 = 19 ; print ( p0 ) ;

Accumulator variables: i, k
Iterator variables: k
Javascript program:
function findOddPair ( A , N ) { let count = 0 ; for ( let i = 0 ; i < N ; i ++ ) if ( ( A [ i ] % 2 == 1 ) ) count ++ ; return count * ( count - 1 ) / 2 ; } let a = [ 5 , 1 , 3 , 2 ] ; let n = a . length ; document . write ( findOddPair ( a , n ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function isSurd ( n ) { for ( let i = 2 ; i * i <= n ; i ++ ) { let j = i ; while ( j < n ) j = j * i ; if ( j == n ) return false ; } return true ; } let n = 15 ; if ( isSurd ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function LastTwoDigit ( num ) { let one = num % 10 ; num = Math . floor ( num / 10 ) ; let tens = num % 10 ; tens *= 10 ; num = tens + one ; return num ; } let n = 10 ; let num = 1 ; num = Math . pow ( 2 , n ) ; document . write ( " " + 2 ) ; document . write ( " " + 2 ) ; document . write ( " " + n + " " ) ; document . write ( LastTwoDigit ( num ) + " " ) ;

Accumulator variables: tens
Javascript program:
function power ( x , y , p ) { while ( y > 0 ) { let r = y & 1 ; if ( r == 1 ) res = ( res * x ) % p ; x = ( x * x ) % p ; } return res ; } function numberOfDigits ( x ) { let i = 0 ; while ( x != 0 ) { x /= 10 ; i ++ ; } return i ; } function LastTwoDigit ( n ) { document . write ( " " + 2 + " " + 2 + " " ) ; document . write ( n + " " ) ; let temp = 1 ; for ( let i = 1 ; i <= 2 ; i ++ ) temp *= 10 ; temp = power ( 2 , n , temp ) ; for ( let i = 0 ; i < ( 2 - numberOfDigits ( temp ) ) ; i ++ ) document . write ( 0 + " " ) ; if ( temp != 0 ) document . write ( temp ) ; } let n = 72 ; LastTwoDigit ( n ) ;

Accumulator variables: i, temp, x
Iterator variables: i
Javascript program:
function countOddSum ( ar , n ) { let result = 0 ; for ( let i = 0 ; i <= n - 1 ; i ++ ) { let val = 0 ; for ( let j = i ; j <= n - 1 ; j ++ ) { val = val + ar [ j ] ; if ( val % 2 != 0 ) result ++ ; } } return ( result ) ; } let ar = [ 5 , 4 , 4 , 5 , 1 , 3 ] ; let n = ar . length ; document . write ( " " + " " ) ; document . write ( countOddSum ( ar , n ) ) ;

Index/key variables: j
Accumulator variables: i, j, result
Iterator variables: i, j
Javascript program:
function countOddSum ( ar , n ) { let temp = [ 1 , 0 ] ; let result = 0 , val = 0 ; for ( let i = 0 ; i <= n - 1 ; i ++ ) { val = ( ( val + ar [ i ] ) % 2 + 2 ) % 2 ; temp [ val ] ++ ; } result = temp [ 0 ] * temp [ 1 ] ; return ( result ) ; } let ar = [ 5 , 4 , 4 , 5 , 1 , 3 ] ; let n = ar . length ; document . write ( " " + " " + countOddSum ( ar , n ) ) ;

Index/key variables: i, val
Accumulator variables: i
Iterator variables: i
Javascript program:
function printPFsInPairs ( n ) { for ( let i = 1 ; i * i <= n ; i ++ ) if ( n % i == 0 ) document . write ( i + " " + parseInt ( n / i ) + " " ) ; } let n = 24 ; printPFsInPairs ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function rangesum ( n , l , r ) { let arr = new Array ( n ) ; let c = 1 , i = 0 ; while ( c <= n ) { arr [ i ++ ] = c ; c += 2 ; } c = 2 ; while ( c <= n ) { arr [ i ++ ] = c ; c += 2 ; } let sum = 0 ; for ( i = l - 1 ; i < r ; i ++ ) { sum += arr [ i ] ; } return sum ; } let n = 12 ; let l = 1 , r = 11 ; document . write ( rangesum ( n , l , r ) ) ;

Index/key variables: i
Accumulator variables: c, i, sum
Iterator variables: i
Javascript program:
function DivisibleBy41 ( first , second , c , n ) { let digit = new Array ( n ) . fill ( 0 ) ; digit [ 0 ] = first ; digit [ 1 ] = second ; for ( let i = 2 ; i < n ; i ++ ) digit [ i ] = ( digit [ i - 1 ] * c + digit [ i - 2 ] ) % 10 ; let ans = digit [ 0 ] ; for ( let i = 1 ; i < n ; i ++ ) ans = ( ans * 10 + digit [ i ] ) % 41 ; if ( ans % 41 == 0 ) return true ; else return false ; } let first = 1 , second = 2 , c = 1 , n = 3 ; if ( DivisibleBy41 ( first , second , c , n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findTetrahedralNumber ( n ) { return ( ( n * ( n + 1 ) * ( n + 2 ) ) / 6 ) ; } function printSeries ( n ) { let prev = 0 ; let curr ; for ( let i = 1 ; i <= n ; i ++ ) { curr = findTetrahedralNumber ( i ) ; curr = curr + prev ; document . write ( curr + " " ) ; prev = curr ; } } let n = 10 ; printSeries ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function printSeries ( n ) { for ( let i = 1 ; i <= n ; i ++ ) { num = ( i * ( i + 1 ) * ( i + 2 ) * ( i + 3 ) / 24 ) ; document . write ( num + " " ) ; } } let n = 10 ; printSeries ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function No_Of_Pairs ( N ) { let i = 1 ; while ( ( i * i * i ) + ( 2 * i * i ) + i <= N ) i ++ ; return ( i - 1 ) ; } function print_pairs ( pairs ) { let i = 1 , mul ; for ( i = 1 ; i <= pairs ; i ++ ) { mul = i * ( i + 1 ) ; document . write ( " " + i + " " + ( mul * i ) + " " + mul * ( i + 1 ) + " " ) ; } } let N = 500 , pairs , mul , i = 1 ; pairs = No_Of_Pairs ( N ) ; document . write ( " " + pairs + " " ) ; print_pairs ( pairs ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function findTriangularNumber ( n ) { return ( n * ( n + 1 ) ) / 2 ; } function printSeries ( n ) { var prev = 0 ; var curr ; for ( var i = 1 ; i <= n ; i ++ ) { curr = findTriangularNumber ( i ) ; curr = curr + prev ; document . write ( curr + " " ) ; prev = curr ; } } var n = 10 ; printSeries ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function printSeries ( n ) { let i ; for ( i = 1 ; i <= n ; i ++ ) { let num = i * ( i + 1 ) * ( ( i + 2 ) / 6 ) ; document . write ( num + " " ) ; } } let n = 10 ; printSeries ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function count_even_odd ( min , max , steps ) { var a , b , even , odd ; var beven = true , aeven = false ; var n = 2 ; for ( i = 0 ; i < n ; i ++ ) { a = steps [ i ] [ 0 ] ; b = steps [ i ] [ 1 ] ; if ( ! ( aeven || ( a & 1 ) > 0 ) ) aeven = true ; if ( beven ) { if ( ( b & 1 ) > 0 ) beven = false ; } else if ( ! ( ( a & 1 ) > 0 ) ) { if ( ! ( ( b & 1 ) > 0 ) ) beven = true ; } else { if ( ( b & 1 ) > 0 ) beven = true ; } } if ( beven ) { even = parseInt ( max / 2 ) - parseInt ( ( min - 1 ) / 2 ) ; odd = 0 ; } else { even = parseInt ( max / 2 ) - parseInt ( ( min - 1 ) / 2 ) ; odd = 0 ; } if ( ! ( beven ^ aeven ) ) even += max - min + 1 - parseInt ( max / 2 ) + parseInt ( ( min - 1 ) / 2 ) ; else odd += max - min + 1 - parseInt ( max / 2 ) + parseInt ( ( min - 1 ) / 2 ) ; document . write ( " " + even + " " + odd ) ; } var min = 1 , max = 4 ; var steps = [ [ 1 , 2 ] , [ 3 , 4 ] ] ; count_even_odd ( min , max , steps ) ;

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Boolean variables: aeven, beven
Javascript program:
function minimumOperations ( a , n ) { let mp = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( mp . get ( a [ i ] ) != null ) { let x = mp . get ( a [ i ] ) ; mp . set ( a [ i ] , ++ x ) ; } else mp . set ( a [ i ] , 1 ) ; } let count = 0 ; for ( let [ key , value ] of mp . entries ( ) ) { if ( value > 1 ) { count += ( value - 1 ) ; } } return count ; } let a = [ 2 , 1 , 2 , 3 , 3 , 4 , 3 ] ; let n = a . length ; document . write ( minimumOperations ( a , n ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function calculate ( x , k , m ) { let result = x ; k = k - 1 ; while ( k -- ) { result = Math . pow ( result , x ) ; if ( result > m ) result %= m ; } return result ; } let x = 5 ; let k = 2 ; let m = 3 ; document . write ( calculate ( x , k , m ) ) ;

Accumulator variables: k
Javascript program:
function fibonacci ( n ) { var fib ; for ( i = 0 ; i < n ; i ++ ) { fib = ( Math . pow ( ( 1 + Math . sqrt ( 5 ) ) , i ) - Math . pow ( ( 1 - Math . sqrt ( 5 ) ) , i ) ) / ( Math . pow ( 2 , i ) * Math . sqrt ( 5 ) ) ; document . write ( parseInt ( fib ) + " " ) ; } } var n = 8 ; fibonacci ( n ) ;

Accumulator variables: i
Iterator variables: i