dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function check_polydivisible ( n ) { let N = n ; let digit = [ ] ; while ( n > 0 ) { digit . push ( n % 10 ) ; n = parseInt ( n / 10 , 10 ) ; } digit . reverse ( ) ; let flag = true ; n = digit [ 0 ] ; for ( let i = 1 ; i < digit . length ; i ++ ) { n = n * 10 + digit [ i ] ; if ( n % ( i + 1 ) != 0 ) { flag = false ; break ; } } if ( flag ) document . write ( N + " " + " " ) ; else document . write ( N + " " ) ; } let n = 345654 ; check_polydivisible ( n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Javascript program:
function Log2n ( n ) { return ( n > 1 ) ? 1 + Log2n ( n / 2 ) : 0 ; } function isPowerOfd ( n , d ) { var count = 0 ; if ( n > 0 && ( n & ( n - 1 ) ) == 0 ) { while ( n > 1 ) { n >>= 1 ; count += 1 ; } return ( count % ( Log2n ( d ) ) == 0 ) ; } return false ; } var n = 64 , d = 8 ; if ( isPowerOfd ( n , d ) ) document . write ( n + " " + d ) ; else document . write ( n + " " + d ) ;

Accumulator variables: count
Javascript program:
var MAX = 1001 ; var adj = Array . from ( Array ( MAX ) , ( ) => Array ( ) ) ; function add_edge ( u , v ) { adj [ u ] . push ( v ) ; } function checkTotalNumberofNodes ( actualAnswer , size ) { var calculatedAnswer = size ; for ( var i = 1 ; i <= size ; i ++ ) calculatedAnswer += adj [ i ] . length ; if ( actualAnswer == calculatedAnswer ) document . write ( " " + calculatedAnswer + " " ) ; else document . write ( " " + " " ) ; } for ( var i = 0 ; i < MAX ; i ++ ) adj [ i ] = [ ] ; var N = 8 ; add_edge ( 1 , 2 ) ; add_edge ( 1 , 3 ) ; add_edge ( 2 , 4 ) ; add_edge ( 2 , 5 ) ; add_edge ( 3 , 6 ) ; add_edge ( 3 , 7 ) ; add_edge ( 6 , 8 ) ; checkTotalNumberofNodes ( 2 * N - 1 , N ) ; for ( var i = 1 ; i <= N ; i ++ ) adj [ i ] = [ ] N = 9 ; add_edge ( 1 , 2 ) ; add_edge ( 1 , 3 ) ; add_edge ( 2 , 4 ) ; add_edge ( 2 , 5 ) ; add_edge ( 2 , 6 ) ; add_edge ( 3 , 9 ) ; add_edge ( 5 , 7 ) ; add_edge ( 5 , 8 ) ; checkTotalNumberofNodes ( 2 * N - 1 , N ) ;

Index/key variables: i, u
Accumulator variables: calculatedAnswer, i
Iterator variables: i
Javascript program:
function seriesSum ( n ) { var sum = 0 ; for ( i = 1 ; i <= n ; i ++ ) sum += i * ( ( i + 1 ) / 2 ) ; return sum ; } var n = 4 ; document . write ( seriesSum ( n ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
let N = 3 function checkCentrosymmetricted ( n , m ) { let mid_row ; if ( n & 1 ) mid_row = Math . floor ( n / 2 ) + 1 ; else mid_row = n / 2 ; for ( let i = 0 ; i < mid_row ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { if ( m [ i ] [ j ] != m [ n - i - 1 ] [ n - j - 1 ] ) return false ; } } return true ; } let n = 3 ; let m = [ [ 1 , 3 , 5 ] , [ 6 , 8 , 6 ] , [ 5 , 3 , 1 ] ] ; ( checkCentrosymmetricted ( n , m ) ? ( document . write ( " " ) ) : document . write ( " " ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function findGCD ( arr , n ) { var result = arr [ 0 ] ; for ( i = 1 ; i < n ; i ++ ) result = gcd ( arr [ i ] , result ) ; return result ; } function compute ( arr , n ) { var answer = new Array ( ) ; var GCD_of_array = findGCD ( arr , n ) ; if ( GCD_of_array == arr [ 0 ] ) { answer . add ( arr [ 0 ] ) ; for ( i = 1 ; i < n ; i ++ ) { answer . add ( arr [ 0 ] ) ; answer . add ( arr [ i ] ) ; } for ( var i = 0 ; i < answer . length ; i ++ ) document . write ( answer [ i ] + " " ) ; } else document . write ( " " + " " ) ; } var n = 3 ; var input = [ 2 , 5 , 6 , 7 , 11 ] ; compute ( input , n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function binomialCoeff ( n , k ) { let C = new Array ( n + 1 ) ; let i , j ; for ( i = 0 ; i <= n ; i ++ ) { C [ i ] = new Array ( k + 1 ) ; for ( j = 0 ; j <= k ; j ++ ) { C [ i ] [ j ] = 0 ; } } for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= Math . min ( i , k ) ; j ++ ) { if ( j == 0 j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } return C [ n ] [ k ] ; } function k_Leaves ( n , k ) { let ans = parseInt ( ( binomialCoeff ( n , k ) * binomialCoeff ( n , k - 1 ) ) / n , 10 ) ; document . write ( " " + " " + " " + ans + " " ) ; return 0 ; } function numberOfNodes ( n , d ) { let ans = binomialCoeff ( 2 * n - 1 - d , n - 1 ) ; document . write ( " " + " " + " " + ans + " " ) ; return 0 ; } function rootDegreeR ( n , r ) { let ans = r * binomialCoeff ( 2 * n - 1 - r , n - 1 ) ; ans = parseInt ( ans / n , 10 ) ; document . write ( " " + " " + " " + ans + " " ) ; return 0 ; } k_Leaves ( 3 , 2 ) ; numberOfNodes ( 3 , 1 ) ; rootDegreeR ( 3 , 2 ) ;

Index/key variables: i, j, k, n
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function repUnitValue ( n ) { if ( n % 2 == 0 n % 5 == 0 ) return 0 ; let rem = 1 ; let power = 1 ; let k = 1 ; while ( rem % n != 0 ) { k ++ ; power = power * 10 % n ; rem = ( rem + power ) % n ; } return k ; } let n = 13 ; document . write ( repUnitValue ( n ) ) ;

Accumulator variables: k
Javascript program:
function isPossibleToZero ( a , n ) { let num = 0 ; for ( let i = 0 ; i < n ; i ++ ) num = num * 10 + a [ i ] ; return ( num % 11 == 0 ) ; } let arr = [ 0 , 1 , 1 , 0 ] ; let n = arr . length ; if ( isPossibleToZero ( arr , n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isBlumInteger ( n ) { let prime = new Array ( n + 1 ) ; for ( let i = 0 ; i < n ; i ++ ) prime [ i ] = true ; for ( let i = 2 ; i * i <= n ; i ++ ) { if ( prime [ i ] == true ) { for ( let j = i * 2 ; j <= n ; j += i ) prime [ j ] = false ; } } for ( let i = 2 ; i <= n ; i ++ ) { if ( prime [ i ] ) { if ( ( n % i == 0 ) && ( ( i - 3 ) % 4 ) == 0 ) { let q = parseInt ( n / i , 10 ) ; return ( q != i && prime [ q ] && ( q - 3 ) % 4 == 0 ) ; } } } return false ; } let n = 249 ; if ( isBlumInteger ( n ) == true ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j, q
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function nCr ( n , r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } function fact ( n ) { var res = 1 ; for ( var i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } var n = 5 , r = 3 ; document . write ( nCr ( n , r ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function find_sum_of_two_squares ( a , b ) { let ab = a * b ; for ( let i = 0 ; i * i <= ab ; i ++ ) { for ( let j = i ; i * i + j * j <= ab ; j ++ ) { if ( i * i + j * j == ab ) document . write ( i + " " + j + " " + ab + " " ) ; } } } let a = 1 * 1 + 2 * 2 ; let b = 3 * 3 + 4 * 4 ; document . write ( " " + " " + " " ) ; find_sum_of_two_squares ( a , b ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function check_euler_four_square_identity ( a , b , ab ) { let s = 0 ; for ( let i = 0 ; i * i <= ab ; i ++ ) { s = i * i ; for ( let j = i ; j * j <= ab ; j ++ ) { s = j * j + i * i ; for ( let k = j ; k * k <= ab ; k ++ ) { s = k * k + j * j + i * i ; for ( let l = k ; l * l <= ab ; l ++ ) { s = l * l + k * k + j * j + i * i ; if ( s == ab ) { document . write ( " " + i + " " ) ; document . write ( " " + j + " " ) ; document . write ( " " + k + " " ) ; document . write ( " " + l + " " ) ; document . write ( " " + a + " " + b ) ; document . write ( " " + " " + " " + " " ) ; document . write ( ab + " " ) ; document . write ( i + " " + i + " " ) ; document . write ( j + " " + j + " " ) ; document . write ( k + " " + k + " " ) ; document . write ( l + " " + l + " " ) ; document . write ( " " ) ; } } } } } } let ab = a * b ; check_euler_four_square_identity ( a , b , ab ) ;

Accumulator variables: i, j, k, l
Iterator variables: i, j, k, l
Javascript program:
function calculateDivisors ( A , B ) { let N = ( A - B ) ; let noOfDivisors = 0 ; for ( let i = 1 ; i <= Math . sqrt ( N ) ; i ++ ) { if ( ( N % i ) == 0 ) { if ( i > B ) noOfDivisors ++ ; if ( ( N / i ) != i && ( N / i ) > B ) noOfDivisors ++ ; } } return noOfDivisors ; } function numberOfPossibleWaysUtil ( A , B ) { if ( A == B ) return - 1 ; if ( A < B ) return 0 ; let noOfDivisors = 0 ; noOfDivisors = calculateDivisors ( A , B ) ; return noOfDivisors ; } function numberOfPossibleWays ( A , B ) { let noOfSolutions = numberOfPossibleWaysUtil ( A , B ) ; if ( noOfSolutions == - 1 ) { document . write ( " " + A + " " + B + " " + " " + " " + A + " " ) ; } else { document . write ( " " + A + " " + B + " " + noOfSolutions + " " + " " ) ; } } let A = 26 , B = 2 ; numberOfPossibleWays ( A , B ) ; A = 21 , B = 5 ; numberOfPossibleWays ( A , B ) ;

Accumulator variables: i, noOfDivisors
Iterator variables: i
Javascript program:
function powerNumbers ( n ) { let v = new Set ( ) ; for ( let i = 2 ; i * i * i <= n ; i ++ ) { let j = i * i ; while ( j * i <= n ) { j *= i ; let s = parseInt ( Math . sqrt ( j ) , 10 ) ; if ( s * s != j ) v . add ( j ) ; } } return v . size + parseInt ( Math . sqrt ( n ) , 10 ) ; } document . write ( powerNumbers ( 50 ) ) ;

Accumulator variables: i, j
Iterator variables: i
Javascript program:
function mean ( a , n ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) for ( let j = 0 ; j < n ; j ++ ) sum += a [ i ] [ j ] ; return sum / ( n * n ) ; } function variance ( a , n , m ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { a [ i ] [ j ] -= m ; a [ i ] [ j ] *= a [ i ] [ j ] ; } } for ( let i = 0 ; i < n ; i ++ ) for ( let j = 0 ; j < n ; j ++ ) sum += a [ i ] [ j ] ; return sum / ( n * n ) ; } let mat = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ] ; let m = mean ( mat , 3 ) ; let varr = variance ( mat , 3 , m ) ; let dev = Math . sqrt ( varr ) ; document . write ( " " + Math . floor ( m ) + " " ) ; document . write ( " " + Math . floor ( varr ) + " " ) ; document . write ( " " + Math . floor ( dev ) + " " ) ;

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Javascript program:
function isValid ( i , m ) { let sq_i = Math . sqrt ( i ) ; let sq = Math . min ( m , sq_i ) ; for ( let j = 2 ; j <= sq ; j ++ ) if ( i % j == 0 ) return false ; return true ; } function findLargestNum ( n , m ) { for ( let i = n ; i > m ; i -- ) { if ( isValid ( i , m ) ) { document . write ( i ) ; return ; } } document . write ( " " ) ; } let n = 16 , m = 3 ; findLargestNum ( n , m ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function printGP ( a , r , n ) { let curr_term ; for ( let i = 0 ; i < n ; i ++ ) { curr_term = a * Math . pow ( r , i ) ; document . write ( curr_term + " " ) ; } } let a = 2 ; let r = 3 ; let n = 5 ; printGP ( a , r , n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( a % b == 0 ) return b ; else return ( gcd ( b , a % b ) ) ; } function findHcf ( arr , size ) { let ans = arr [ 0 ] [ 0 ] ; for ( let i = 1 ; i < size ; i ++ ) ans = gcd ( ans , arr [ i ] [ 0 ] ) ; return ( ans ) ; } function findLcm ( arr , size ) { let ans = arr [ 0 ] [ 1 ] ; for ( let i = 1 ; i < size ; i ++ ) ans = Math . floor ( ( ( arr [ i ] [ 1 ] * ans ) ) / ( gcd ( arr [ i ] [ 1 ] , ans ) ) ) ; return ( ans ) ; } function hcfOfFraction ( arr , size ) { let hcf_of_num = findHcf ( arr , size ) ; let lcm_of_deno = findLcm ( arr , size ) ; let result = new Array ( 2 ) ; result [ 0 ] = hcf_of_num ; result [ 1 ] = lcm_of_deno ; for ( let i = result [ 0 ] / 2 ; i > 1 ; i -- ) { if ( ( result [ 1 ] % i == 0 ) && ( result [ 0 ] % i == 0 ) ) { result [ 1 ] /= i ; result [ 0 ] /= i ; } } return ( result ) ; } let size = 4 ; let arr = new Array ( size ) ; for ( let i = 0 ; i < size ; i ++ ) arr [ i ] = new Array ( 2 ) ; arr [ 0 ] [ 0 ] = 9 ; arr [ 0 ] [ 1 ] = 10 ; arr [ 1 ] [ 0 ] = 12 ; arr [ 1 ] [ 1 ] = 25 ; arr [ 2 ] [ 0 ] = 18 ; arr [ 2 ] [ 1 ] = 35 ; arr [ 3 ] [ 0 ] = 21 ; arr [ 3 ] [ 1 ] = 40 ; let result = hcfOfFraction ( arr , size ) ; document . write ( result [ 0 ] + " " + result [ 1 ] + " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function getMSB ( n ) { n |= n >> 1 ; n |= n >> 2 ; n |= n >> 4 ; n |= n >> 8 ; n |= n >> 16 ; return ( ( n + 1 ) >> 2 ) ; } function multiply ( F , M ) { let x = F [ 0 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 0 ] ; let y = F [ 0 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 0 ] [ 1 ] * M [ 1 ] [ 1 ] ; let z = F [ 1 ] [ 0 ] * M [ 0 ] [ 0 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 0 ] ; let w = F [ 1 ] [ 0 ] * M [ 0 ] [ 1 ] + F [ 1 ] [ 1 ] * M [ 1 ] [ 1 ] ; F [ 0 ] [ 0 ] = x ; F [ 0 ] [ 1 ] = y ; F [ 1 ] [ 0 ] = z ; F [ 1 ] [ 1 ] = w ; } function power ( F , n ) { if ( n == 0 n == 1 ) return ; let M = [ [ 1 , 1 ] , [ 1 , 0 ] ] ; for ( let m = getMSB ( n ) ; m > 0 ; m = m >> 1 ) { multiply ( F , F ) ; if ( ( n & m ) > 0 ) { multiply ( F , M ) ; } } } function fib ( n ) { let F = [ [ 1 , 1 ] , [ 1 , 0 ] ] ; if ( n == 0 ) return 0 ; power ( F , n - 1 ) ; return F [ 0 ] [ 0 ] ; } let n = 6 ; document . write ( fib ( n ) ) ;

Accumulator variables: n
Iterator variables: m
Javascript program:
function SternSequenceFunc ( BrocotSequence , n ) { for ( var i = 1 ; BrocotSequence . length < n ; i ++ ) { var considered_element = BrocotSequence [ i ] ; var precedent = BrocotSequence [ i - 1 ] ; BrocotSequence . push ( considered_element + precedent ) ; BrocotSequence . push ( considered_element ) ; } for ( var i = 0 ; i < 15 ; ++ i ) document . write ( BrocotSequence [ i ] + " " ) ; } var n = 15 ; var BrocotSequence = [ ] ; BrocotSequence . push ( 1 ) ; BrocotSequence . push ( 1 ) ; SternSequenceFunc ( BrocotSequence , n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isRevDiffDivisible ( x , k ) { var n = x ; var m = 0 ; var flag ; while ( x > 0 ) { m = m * 10 + x % 10 ; x = parseInt ( x / 10 ) ; } return ( Math . abs ( n - m ) % k == 0 ) ; } function countNumbers ( l , r , k ) { var count = 0 ; for ( i = l ; i <= r ; i ++ ) if ( isRevDiffDivisible ( i , k ) ) count ++ ; return count ; } var l = 35 , r = 45 , k = 5 ; document . write ( countNumbers ( l , r , k ) ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function divSum ( n ) { let result = 0 ; for ( let i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == ( n / i ) ) result += i ; else result += ( i + n / i ) ; } } return ( result + 1 ) ; } function areAmicable ( x , y ) { if ( divSum ( x ) != y ) return false ; return ( divSum ( y ) == x ) ; } let x = 220 ; let y = 284 ; if ( areAmicable ( x , y ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i, result
Iterator variables: i
Javascript program:
function isPerfectSquare ( n ) { if ( n < 0 ) return false ; let root = Math . round ( ( Math . sqrt ( n ) ) ) ; return n == root * root ; } function printnonsquare ( n ) { let count = 0 ; for ( let i = 1 ; count < n ; ++ i ) { if ( ! isPerfectSquare ( i ) ) { document . write ( i + " " ) ; count ++ ; } } } let n = 10 ; printnonsquare ( n ) ;

Accumulator variables: count
Iterator variables: i
Javascript program:
function nonsquare ( n ) { return n + parseInt ( 0.5 + Math . sqrt ( n ) ) ; } function printNonSquare ( n ) { for ( let i = 1 ; i <= n ; i ++ ) document . write ( nonsquare ( i ) + " " ) ; } let n = 10 ; printNonSquare ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function getLudic ( n ) { let ludics = [ ] ; for ( let i = 1 ; i <= n ; i ++ ) ludics . push ( i ) ; for ( let index = 1 ; index < ludics . length ; index ++ ) { let first_ludic = ludics [ index ] ; let remove_index = index + first_ludic ; while ( remove_index < ludics . length ) { ludics . splice ( remove_index , 1 ) ; remove_index = remove_index + first_ludic - 1 ; } } return ludics ; } let n = 25 ; document . write ( getLudic ( n ) ) ;

Index/key variables: index
Accumulator variables: i, index
Iterator variables: i, index
Javascript program:
function nearestPerfectSquare ( arr , N ) { for ( let i = 0 ; i < N ; i ++ ) { let sr = Math . floor ( Math . sqrt ( arr [ i ] ) ) ; if ( ( sr & 1 ) == ( arr [ i ] & 1 ) ) document . write ( ( sr * sr ) + " " ) ; else { sr ++ ; document . write ( ( sr * sr ) + " " ) ; } } } let arr = [ 6 , 3 , 2 , 15 ] ; let N = arr . length ; nearestPerfectSquare ( arr , N ) ;

Index/key variables: i
Accumulator variables: i, sr
Iterator variables: i
Javascript program:
function isPentagonal ( N ) { var i = 1 , M ; do { M = ( 3 * i * i - i ) / 2 ; i += 1 ; } while ( M < N ) ; return ( M == N ) ; } var N = 12 ; if ( isPentagonal ( N ) ) document . write ( N + " " ) ; else document . write ( N + " " ) ;

Accumulator variables: i
Javascript program:
function aliquotSum ( n ) { let sum = 0 ; for ( let i = 1 ; i < n ; i ++ ) if ( n % i == 0 ) sum += i ; return sum ; } let n = 12 ; document . write ( aliquotSum ( n ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function func ( x ) { return ( 1 / ( 1 + x * x ) ) ; } function calculate ( lower_limit , upper_limit , interval_limit ) { let value ; let interval_size = ( upper_limit - lower_limit ) / interval_limit ; let sum = func ( lower_limit ) + func ( upper_limit ) ; for ( let i = 1 ; i < interval_limit ; i ++ ) { if ( i % 3 == 0 ) sum = sum + 2 * func ( lower_limit + i * interval_size ) ; else sum = sum + 3 * func ( lower_limit + i * interval_size ) ; } return ( 3 * interval_size / 8 ) * sum ; } let interval_limit = 10 ; let lower_limit = 1 ; let upper_limit = 10 ; let integral_res = calculate ( lower_limit , upper_limit , interval_limit ) ; document . write ( integral_res ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function maxArea ( A , len ) { let area = 0 ; for ( let i = 0 ; i < len ; i ++ ) { for ( let j = i + 1 ; j < len ; j ++ ) { area = Math . max ( area , Math . min ( A [ j ] , A [ i ] ) * ( j - i ) ) ; } } return area ; } let a = [ 1 , 5 , 4 , 3 ] ; let b = [ 3 , 1 , 2 , 4 , 5 ] ; let len1 = a . length ; document . write ( maxArea ( a , len1 ) + " " ) ; let len2 = b . length ; document . write ( maxArea ( b , len2 ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function check ( n ) { let m = n ; while ( n ) { let r = n % 10 ; if ( r > 0 ) if ( ( n % r ) != 0 ) return false ; n /= 10 ; } return true ; } function countIn ( l , r ) { let ans = 0 ; for ( let i = l ; i <= r ; i ++ ) if ( check ( i ) ) ans += 1 ; return ans ; } let l = 10 ; let r = 20 ; document . write ( countIn ( l , r ) ) ;

Accumulator variables: ans, i, n
Iterator variables: i
Javascript program:
function sumOfTheSeries ( n ) { let sum = 0.0 ; for ( let i = 1 ; i <= n ; i ++ ) sum += 1.0 / ( i * ( i + 1 ) ) ; return sum ; } let n = 10 ; document . write ( sumOfTheSeries ( n ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function sum ( n ) { let root = parseInt ( Math . sqrt ( n ) ) ; let ans = 0 ; for ( let i = 1 ; i <= root ; i ++ ) ans += parseInt ( n / i ) ; ans = ( 2 * ans ) - ( root * root ) ; return ans ; } let n = 35 ; document . write ( sum ( n ) ) ;

Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function sumofsquare ( n ) { let C = new Array ( n + 1 ) ; for ( let i = 0 ; i < C . length ; i ++ ) { C [ i ] = new Array ( 2 ) ; } let i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= Math . min ( i , n ) ; j ++ ) { if ( j == 0 j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } let sum = 0 ; for ( i = 0 ; i <= n ; i ++ ) sum += ( C [ n ] [ i ] * C [ n ] [ i ] ) ; return sum ; } let n = 4 ; document . write ( sumofsquare ( n ) ) ;

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

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function evenSum ( n ) { var C = Array . from ( Array ( n + 1 ) , ( ) => Array ( n + 1 ) . fill ( 0 ) ) ; var i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= Math . min ( i , n ) ; j ++ ) { if ( j == 0 j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } var sum = 0 ; for ( var i = 0 ; i <= n ; i += 2 ) sum += C [ n ] [ i ] ; return sum ; } var n = 4 ; document . write ( evenSum ( n ) ) ;

Index/key variables: i, j, n
Accumulator variables: i, j, sum
Iterator variables: i, j
Javascript program:
function triangular_series ( n ) { for ( let i = 1 ; i <= n ; i ++ ) document . write ( " " + i * ( i + 1 ) / 2 ) ; } let n = 5 ; triangular_series ( n ) ;

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

Accumulator variables: sum
Iterator variables: i
Javascript program:
function sum_all_divisors ( num ) { var sum = 0 ; for ( var i = 1 ; i <= Math . sqrt ( num ) ; i ++ ) { sum += t1 + t2 ; } return sum ; } var n ; var sum = sum_all_divisors ( n ) ; document . write ( sum ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function polite ( n ) { n += 1 ; let base = 2 ; return n + ( Math . log ( ( n + ( Math . log ( n ) / Math . log ( base ) ) ) ) ) / Math . log ( base ) ; } n = 7 ; document . write ( parseInt ( polite ( n ) ) ) ;

Accumulator variables: n
Javascript program:
function solve ( low , high , T ) { while ( low <= high ) { let mid = Math . floor ( ( low + high ) / 2 ) ; if ( ( mid * ( mid + 1 ) ) == T ) return mid ; if ( mid > 0 && ( mid * ( mid + 1 ) ) > T && ( mid * ( mid - 1 ) ) <= T ) return mid - 1 ; if ( ( mid * ( mid + 1 ) ) > T ) high = mid - 1 ; else low = mid + 1 ; } return - 1 ; } let T = 15 ; let ans = solve ( 1 , T , 2 * T ) ; if ( ans != - 1 ) ans -- ; document . write ( " " + ans ) ;

Accumulator variables: ans
Javascript program:
function oddSum ( n ) { let sum = 0 ; curr = 1 ; for ( let i = 0 ; i < n ; i ++ ) { sum += curr ; curr += 2 ; } return sum ; } let n = 20 ; document . write ( " " + n + " " + oddSum ( n ) ) ;

Accumulator variables: curr, i, sum
Iterator variables: i
Javascript program:
function prletKPFNums ( A , B , K ) { let prime = [ ] ; for ( let i = 0 ; i < B + 1 ; i ++ ) prime [ i ] = true ; let p_factors = [ ] ; for ( let i = 0 ; i < B + 1 ; i ++ ) p_factors [ i ] = 0 ; for ( let p = 2 ; p <= B ; p ++ ) if ( p_factors [ p ] == 0 ) for ( let i = p ; i <= B ; i += p ) p_factors [ i ] ++ ; for ( let i = A ; i <= B ; i ++ ) if ( p_factors [ i ] == K ) document . write ( i + " " ) ; } let A = 14 , B = 18 , K = 2 ; prletKPFNums ( A , B , K ) ;

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Javascript program:
let MAX = 100005 ; function precompute ( prefix , suffix ) { let prime = [ ] ; for ( let i = 0 ; i < MAX ; i ++ ) { prime [ i ] = true ; } for ( let i = 2 ; i * i < MAX ; i ++ ) { if ( prime [ i ] ) { for ( let j = i * i ; j < MAX ; j += i ) { prime [ j ] = false ; } } } prefix [ 1 ] = 1 ; suffix [ MAX - 1 ] = 1e9 + 7 ; for ( let i = 2 ; i < MAX ; i ++ ) { if ( prime [ i ] ) { prefix [ i ] = i ; } else { prefix [ i ] = prefix [ i - 1 ] ; } } for ( let i = MAX - 2 ; i > 1 ; i -- ) { if ( prime [ i ] ) { suffix [ i ] = i ; } else { suffix [ i ] = suffix [ i + 1 ] ; } } } function query ( prefix , suffix , L , R ) { if ( prefix [ R ] < L suffix [ L ] > R ) { return 0 ; } else { return prefix [ R ] - suffix [ L ] ; } } let q = 3 ; let L = [ 2 , 2 , 24 ] ; let R = [ 5 , 2 , 28 ] ; let prefix = [ ] , suffix = [ ] ; precompute ( prefix , suffix ) ; for ( let i = 0 ; i < q ; i ++ ) { document . write ( query ( prefix , suffix , L [ i ] , R [ i ] ) + " " ) ; }

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