dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function printSeriesSum ( N ) { let sum = 0 ; for ( let i = 1 ; i <= N ; i ++ ) { sum += Math . pow ( i , i - 1 ) ; } document . write ( sum ) ; } let N = 5 ; printSeriesSum ( N ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function printSumSeries ( N ) { let sum = 0 ; for ( let i = 1 ; i <= N ; i ++ ) { sum += 1.0 / ( 2 * i - 1 ) ; } document . write ( sum . toFixed ( 5 ) ) ; } let N = 6 ; printSumSeries ( N ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function printSeriesSum ( N ) { let sum = 0 ; let a = 1 ; let cnt = 0 ; let flag = true ; sum += a ; while ( cnt < N ) { let nextElement ; if ( flag ) { nextElement = a * 2 ; sum += nextElement ; flag = ! flag ; } else { nextElement = a * 3 / 2 ; sum += nextElement ; flag = ! flag ; } a = nextElement ; cnt ++ ; } document . write ( sum ) ; } let N = 8 ; printSeriesSum ( N ) ;

Accumulator variables: cnt, sum
Boolean variables: flag
Javascript program:
function sumBaseB ( a , b , base_var ) { let len_a , len_b ; len_a = a . length ; len_b = b . length ; let sum , s ; s = " " ; sum = " " ; let diff ; diff = Math . abs ( len_a - len_b ) ; for ( let i = 1 ; i <= diff ; i ++ ) s += " " ; if ( len_a < len_b ) a = s + a ; else b = s + b ; let curr , carry = 0 ; for ( let i = Math . max ( len_a , len_b ) - 1 ; i > - 1 ; i -- ) { curr = carry + ( a [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) + ( b [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) ; carry = parseInt ( curr / base_var , 10 ) ; curr = curr % base_var ; sum = String . fromCharCode ( curr + ' ' . charCodeAt ( ) ) + sum ; } if ( carry > 0 ) sum = String . fromCharCode ( carry + ' ' . charCodeAt ( ) ) + sum ; return sum ; } let a , b , sum ; let base_var ; a = " " ; b = " " ; base_var = 6 ; sum = sumBaseB ( a , b , base_var ) ; document . write ( sum + " " ) ;

Index/key variables: i
Accumulator variables: i, s
Iterator variables: i
Javascript program:
function MinimumSwapOperations ( s ) { let zero_exist = false ; let multiple_of_2 = false ; let sum = 0 ; let index_of_zero = 0 ; let more_zero = false ; for ( let i = 0 ; i < s . length ; i ++ ) { let val = s [ i ] - ' ' ; if ( zero_exist == true ) more_zero = true ; if ( val == 0 ) { zero_exist = true ; index_of_zero = i ; } sum += val ; } if ( zero_exist == false sum % 3 != 0 ) { document . write ( " " ) ; return ; } for ( let i = 0 ; i < s . length ; i ++ ) { let val = s [ i ] - ' ' ; if ( val % 2 == 0 && i != index_of_zero ) multiple_of_2 = true ; } if ( multiple_of_2 == false ) { document . write ( " " ) ; return ; } let last_val = s . charAt [ s . length - 1 ] - ' ' ; let second_last_val = s [ ( s . length - 2 ) ] - ' ' ; if ( last_val == 0 && second_last_val % 2 == 0 ) document . write ( 0 ) ; else if ( ( last_val == 0 && second_last_val % 2 != 0 ) || ( last_val % 2 == 0 && second_last_val == 0 ) ) document . write ( 1 ) ; else if ( more_zero == true && ( last_val == 0 && second_last_val % 2 != 0 ) ) document . write ( 1 ) ; else document . write ( 2 ) ; } let N = " " ; MinimumSwapOperations ( N ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Boolean variables: more_zero, multiple_of_2, zero_exist
Javascript program:
function isPalindrome ( x ) { let num = x . toString ( ) ; let result = true ; let i = 0 ; let j = num . length - 1 ; while ( i < j && result ) { result = num [ i ++ ] == num [ j -- ] ; } return result ; } function find ( nDigits ) { let lowerBound = Math . floor ( Math . pow ( 10 , nDigits - 1 ) ) ; let upperBound = ( lowerBound * 10 ) - 1 ; let resultP = 0 , resultQ = 0 , resultR = 0 ; for ( let p = upperBound ; p > lowerBound ; p -= 11 ) { while ( p % 11 != 0 ) { p -- ; } for ( let q = upperBound ; q > lowerBound ; q -- ) { let t = p * q ; if ( t > resultR && isPalindrome ( t ) ) { resultP = p ; resultQ = q ; resultR = t ; break ; } } } document . write ( resultR ) ; } let N = 2 ; find ( N ) ;

Accumulator variables: i, j, p, q
Iterator variables: p, q
Boolean variables: result
Javascript program:
let MAX = 1000 ; let max_prime = Array . from ( { length : MAX } , ( _ , i ) => 0 ) ; let min_prime = Array . from ( { length : MAX } , ( _ , i ) => 0 ) ; function sieve ( n ) { for ( let i = 2 ; i < n ; ++ i ) { if ( min_prime [ i ] > 0 ) { continue ; } min_prime [ i ] = i ; max_prime [ i ] = i ; let j = i + i ; while ( j < n ) { if ( min_prime [ j ] == 0 ) { min_prime [ j ] = i ; } max_prime [ j ] = i ; j += i ; } } } function findCost ( A , B , C , X ) { sieve ( MAX ) ; let N , M ; if ( X == 1 ) { return - 1 ; } let min_cost = C + X ; let cost_for_prime = A ; N = max_prime [ X ] ; if ( N != X ) { M = X / N ; cost_for_prime += M ; min_cost = Math . min ( min_cost , cost_for_prime ) ; } M = min_prime [ X ] ; N = X / M ; if ( N != min_prime [ N ] ) { let cost_for_comp = B + M ; min_cost = Math . min ( min_cost , cost_for_comp ) ; } return min_cost ; } let A = 7 , B = 11 , C = 2 , X = 20 ; document . write ( findCost ( A , B , C , X ) ) ;

Index/key variables: N, X, i, j
Accumulator variables: cost_for_prime, j
Iterator variables: i
Javascript program:
function printModulus ( X , Y ) { var n = Math . max ( X , Y ) ; for ( var i = 1 ; i <= n ; i ++ ) { if ( X % i == Y % i ) document . write ( i + " " ) ; } } X = 10 ; Y = 20 ; printModulus ( X , Y ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function printModulus ( X , Y ) { var d = Math . abs ( X - Y ) ; var i = 1 ; while ( i * i <= d ) { if ( d % i == 0 ) { document . write ( i + " " ) ; if ( d / i != i ) document . write ( parseInt ( d / i ) + " " ) ; } i ++ ; } } var X = 10 ; var Y = 26 ; printModulus ( X , Y ) ;

Accumulator variables: i
Javascript program:
function createHash ( hash , maxElement ) { let prev = 0 , curr = 1 ; hash . add ( prev ) ; hash . add ( curr ) ; while ( curr <= maxElement ) { let temp = curr + prev ; hash . add ( temp ) ; prev = curr ; curr = temp ; } } function countFibonacciDivisors ( n ) { let hash = new Set ( ) ; createHash ( hash , n ) ; let cnt = 0 ; for ( let i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( ( n / i == i ) && ( hash . has ( n / i ) ) ) cnt ++ ; else { if ( hash . has ( n / i ) ) cnt ++ ; if ( hash . has ( n / ( n / i ) ) ) cnt ++ ; } } } return cnt ; } let n = 12 ; document . write ( countFibonacciDivisors ( n ) ) ;

Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . left = null ; this . right = null ; } } ; var res = 0 ; var k = 0 ; function newNode ( data ) { var newNode = new Node ( ) ; newNode . data = data ; newNode . left = null ; newNode . right = null ; return newNode ; } function rec ( root ) { if ( root == null ) { return 0 ; } xr ^= rec ( root . left ) ; xr ^= rec ( root . right ) ; if ( xr == k ) { res ++ ; } return xr ; } function findCount ( root , K ) { res = 0 ; k = K ; rec ( root ) ; return res ; } var root = newNode ( 2 ) ; root . left = newNode ( 1 ) ; root . right = newNode ( 9 ) ; root . left . left = newNode ( 10 ) ; root . left . right = newNode ( 5 ) ; var K = 5 ; document . write ( findCount ( root , K ) ) ;

Accumulator variables: res, xr
Class/struct names: Node
Javascript program:
function makearrayequal ( arr , n ) { var x = 0 ; for ( i = 0 ; i < n ; i ++ ) { x += ( arr [ i ] & 1 ) ; } document . write ( Math . min ( x , n - x ) ) ; } var arr = [ 4 , 3 , 2 , 1 ] ; var n = arr . length ; makearrayequal ( arr , n ) ;

Index/key variables: i
Accumulator variables: i, x
Iterator variables: i
Javascript program:
function countDigit ( n ) { let temp = n , count = 0 ; while ( temp != 0 ) { let d = temp % 10 ; temp = Math . floor ( temp / 10 ) ; if ( d == 2 d == 3 d == 5 d == 7 ) count ++ ; } return count ; } let n = 1234567890 ; document . write ( countDigit ( n ) + " " ) ;

Accumulator variables: count
Javascript program:
function permutation ( arr , N ) { var hash = Array ( N + 1 ) . fill ( 0 ) ; for ( var i = 0 ; i < N ; i ++ ) { hash [ arr [ i ] ] ++ ; } for ( var i = 1 ; i <= N ; i ++ ) { if ( hash [ i ] != 1 ) return " " ; } return " " ; } var arr = [ 1 , 1 , 5 , 5 , 3 ] ; var n = arr . length ; document . write ( permutation ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function check ( arr , n ) { let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] & 1 ) count ++ ; } if ( count & 1 ) return " " ; else return " " ; } let arr = [ 3 , 9 , 12 , 13 , 15 ] ; let n = arr . length ; document . write ( check ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
let N = 100005 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 longestPrimeSubsequence ( arr , n ) { let prime = new Array ( N + 1 ) ; prime . fill ( true ) SieveOfEratosthenes ( prime , N ) ; let answer = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) { answer ++ ; } } return answer ; } let arr = [ 3 , 4 , 11 , 2 , 9 , 21 ] ; let n = arr . length document . write ( longestPrimeSubsequence ( arr , n ) + " " ) ;

Index/key variables: i, p
Accumulator variables: answer, i, p
Iterator variables: i, p
Javascript program:
function dydx ( x , y ) { return ( x + y - 2 ) ; } function rungeKutta ( x0 , y0 , x , h ) { let n = ( ( x - x0 ) / h ) ; let k1 , k2 ; let y = y0 ; for ( let i = 1 ; i <= n ; i ++ ) { k1 = h * dydx ( x0 , y ) ; k2 = h * dydx ( x0 + 0.5 * h , y + 0.5 * k1 ) ; y = y + ( 1.0 / 6.0 ) * ( k1 + 2 * k2 ) ; x0 = x0 + h ; } return y ; } let x0 = 0 , y = 1 , x = 2 , h = 0.2 ; document . write ( rungeKutta ( x0 , y , x , h ) . toFixed ( 6 ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
var size = 10001 var fib = Array ( 100010 ) . fill ( 0 ) ; var freq = Array ( 100010 ) . fill ( 0 ) ; function isPerfectSquare ( x ) { var s = parseInt ( Math . sqrt ( x ) ) ; return ( s * s == x ) ; } function isFibonacci ( n ) { if ( isPerfectSquare ( 5 * n * n + 4 ) || isPerfectSquare ( 5 * n * n - 4 ) ) return 1 ; return 0 ; } function compute ( a , b ) { for ( var i = 1 ; i < 100010 ; i ++ ) { fib [ i ] = isFibonacci ( i ) ; } for ( var x = 1 ; x < 100010 ; x ++ ) { for ( var y = 1 ; y < size ; y ++ ) { if ( fib [ x ] == 1 && fib [ y ] == 1 && a * x + b * y < 100010 ) { freq [ a * x + b * y ] ++ ; } } } } var Q = 2 , A = 5 , B = 10 ; compute ( A , B ) ; var arr = [ 50 , 150 ] ; for ( var i = 0 ; i < Q ; i ++ ) { document . write ( freq [ arr [ i ] ] + " " ) ; }

Index/key variables: i, x, y
Accumulator variables: i, x, y
Iterator variables: i, x, y
Javascript program:
let MAX = 100 ; function max_element ( arr , pos ) { let tmp = arr [ 0 ] ; let ind = 0 ; for ( let i = 1 ; i < pos ; i ++ ) { if ( tmp < arr [ i ] ) { tmp = arr [ i ] ; ind = i ; } } return ind ; } function findMaxSum ( n1 , n2 ) { let arr1 = Array . from ( { length : MAX } , ( _ , i ) => 0 ) ; let arr2 = Array . from ( { length : MAX } , ( _ , i ) => 0 ) ; let l1 = 0 , l2 = 0 ; let max1 = Math . max ( n1 , n2 ) ; let min1 = Math . min ( n1 , n2 ) ; for ( let i = max1 ; i > 0 ; i = Math . floor ( i / 10 ) ) arr1 [ l1 ++ ] = ( i % 10 ) ; for ( let i = min1 ; i > 0 ; i = Math . floor ( i / 10 ) ) arr2 [ l2 ++ ] = ( i % 10 ) ; let f = 0 ; if ( l1 != l2 ) { let index = ( max_element ( arr2 , l2 ) ) ; for ( let i = l1 - 1 ; i > ( l2 - 1 ) ; i -- ) { if ( arr1 [ i ] < arr2 [ index ] ) { let tmp = arr1 [ i ] ; arr1 [ i ] = arr2 [ index ] ; arr2 [ index ] = tmp ; f = 1 ; break ; } } } if ( f != 1 ) { let index1 = 0 , index2 = 0 ; let diff1 = 0 , diff2 = 0 ; for ( let i = l2 - 1 ; i >= 0 ; i -- ) { index1 = ( max_element ( arr1 , i ) ) ; index2 = ( max_element ( arr2 , i ) ) ; diff1 = ( arr2 [ index2 ] - arr1 [ i ] ) ; diff2 = ( arr1 [ index1 ] - arr2 [ i ] ) ; if ( diff1 > 0 diff2 > 0 ) { if ( diff1 > diff2 ) { let tmp = arr1 [ i ] ; arr1 [ i ] = arr2 [ index2 ] ; arr2 [ index2 ] = tmp ; break ; } else if ( diff2 > diff1 ) { let tmp = arr1 [ index1 ] ; arr1 [ index1 ] = arr2 [ i ] ; arr2 [ i ] = tmp ; break ; } else if ( diff1 == diff2 ) { if ( index1 <= index2 ) { let tmp = arr1 [ index1 ] ; arr1 [ index1 ] = arr2 [ i ] ; arr2 [ i ] = tmp ; break ; } else if ( index2 <= index1 ) { let tmp = arr1 [ i ] ; arr1 [ i ] = arr2 [ index2 ] ; arr2 [ index2 ] = tmp ; break ; } } } } } let f_n1 = 0 , f_n2 = 0 ; for ( let i = l1 - 1 ; i >= 0 ; i -- ) { f_n1 = ( f_n1 * 10 ) + arr1 [ i ] ; f_n2 = ( f_n2 * 10 ) + arr2 [ i ] ; } document . write ( f_n1 + f_n2 ) ; } let N1 = 9987 ; let N2 = 123 ; findMaxSum ( N1 , N2 ) ;

Index/key variables: i, index, index1, index2
Accumulator variables: i, l1, l2
Iterator variables: i
Javascript program:
function print ( n , k ) { document . write ( k + " " ) ; for ( var i = 2 ; i <= n ; i ++ ) { var x = Math . pow ( k , i ) - Math . pow ( k , i - 1 ) ; document . write ( x + " " ) ; } } var N = 3 , K = 4 ; print ( N , K ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function countDigit ( n ) { var prime = Array ( 10 ) . fill ( false ) ; prime [ 2 ] = prime [ 3 ] = true ; prime [ 5 ] = prime [ 7 ] = true ; var temp = n , count = 0 ; while ( temp != 0 ) { var d = temp % 10 ; temp = parseInt ( temp / 10 ) ; if ( d > 0 && n % d == 0 && prime [ d ] ) count ++ ; } return count ; } n = 1032 ; document . write ( countDigit ( n ) ) ;

Index/key variables: d
Accumulator variables: count
Javascript program:
let digit = [ ] ; function findDigits ( n ) { let count = 0 ; while ( n != 0 ) { digit [ count ] = n % 10 ; n = n / 10 ; ++ count ; } return count ; } function OR_of_Digits ( n , count ) { let ans = 0 ; for ( let i = 0 ; i < count ; i ++ ) { ans = ans | digit [ i ] ; } return ans ; } function AND_of_Digits ( n , count ) { let ans = 0 ; for ( let i = 0 ; i < count ; i ++ ) { ans = ans & digit [ i ] ; } return ans ; } function XOR_of_Digits ( n , count ) { let ans = 0 ; for ( let i = 0 ; i < count ; i ++ ) { ans = ans ^ digit [ i ] ; } return ans ; } function bitwise_operation ( N ) { let countOfDigit = findDigits ( N ) ; document . write ( " " + XOR_of_Digits ( N , countOfDigit ) + " " ) ; document . write ( " " + OR_of_Digits ( N , countOfDigit ) + " " ) ; document . write ( " " + AND_of_Digits ( N , countOfDigit ) + " " ) ; } let N = 123456 ; bitwise_operation ( N ) ;

Index/key variables: count, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function maxLength ( arr , N ) { var product = 1 , len = 0 ; for ( var i = 0 ; i < N ; i ++ ) { product *= arr [ i ] ; } if ( product >= 0 ) { return N ; } for ( var i = 0 ; i < N ; i ++ ) { if ( arr [ i ] < 0 ) { len = Math . max ( len , Math . max ( N - i - 1 , i ) ) ; } } return len ; } var arr = [ - 1 , 1 , 1 , - 2 , 3 , 2 , - 1 ] ; var N = arr . length ; document . write ( maxLength ( arr , N ) ) ;

Index/key variables: i
Accumulator variables: i, product
Iterator variables: i
Javascript program:
function findNumbers ( N ) { let i = 1 ; while ( i <= N ) { document . write ( ( i * i * i ) + " " ) ; i ++ ; } } let N = 4 ; findNumbers ( N ) ;

Accumulator variables: i
Javascript program:
function properDivisorSum ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; ++ i ) { for ( let j = 1 ; j * j <= i ; ++ j ) { if ( i % j == 0 ) { if ( i / j == j ) sum += j ; else sum += j + i / j ; } } sum = sum - i ; } return sum ; } let n = 4 ; document . write ( properDivisorSum ( n ) + " " ) ; n = 5 ; document . write ( properDivisorSum ( n ) + " " ) ;

Accumulator variables: sum
Iterator variables: i, j
Javascript program:
function properDivisorSum ( n ) { var sum = 0 ; for ( var i = 1 ; i <= n ; ++ i ) sum += parseInt ( n / i ) * i ; return sum - n * ( ( n + 1 ) / 2 ) ; } var n = 4 ; document . write ( properDivisorSum ( n ) + " " ) ; n = 5 ; document . write ( properDivisorSum ( n ) + " " ) ;

Accumulator variables: sum
Iterator variables: i
Javascript program:
function findMinimumOperation ( n , d , arrays ) { var cnt = 0 ; var first = Number . MIN_VALUE , end = Number . MAX_VALUE ; while ( n > 0 ) { var arr = [ arrays [ cnt ] [ 0 ] , arrays [ cnt ] [ 1 ] ] ; arr . sort ( ( a , b ) => a - b ) ; first = Math . max ( first , arr [ 0 ] ) ; end = Math . min ( end , arr [ 1 ] ) ; cnt ++ ; n -- ; } if ( first > end ) document . write ( " " ) ; else { if ( d >= first && d <= end ) { document . write ( " " ) ; } else document . write ( Math . min ( Math . abs ( first - d ) , Math . abs ( d - end ) ) ) ; } } var n = 3 , d = 3 ; var arrays = [ [ 0 , 7 ] , [ 2 , 14 ] , [ 4 , 6 ] ] ; findMinimumOperation ( n , d , arrays ) ;

Index/key variables: cnt
Accumulator variables: cnt, n
Javascript program:
mod = 1000000007 ; function mult ( a , b ) { return ( ( a % mod ) * ( b % mod ) ) % mod ; } function calculate_factors ( n ) { var ans , cnt ; cnt = 0 ; ans = 1 ; while ( n % 2 == 0 ) { cnt ++ ; n = n / 2 ; } if ( cnt % 2 == 1 ) { ans = mult ( ans , ( cnt + 1 ) ) ; } for ( i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { cnt = 0 ; while ( n % i == 0 ) { cnt ++ ; n = n / i ; } if ( cnt % 2 == 1 ) { ans = mult ( ans , ( cnt + 1 ) ) ; } } if ( n > 2 ) { ans = mult ( ans , ( 2 ) ) ; } return ans % mod ; } var n = 193748576239475639 ; mod = 17 ; document . write ( calculate_factors ( n ) ) ;

Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function maxValue ( a ) { var c = a . toString ( 2 ) ; var b = " " ; for ( var i = 0 ; i < c . length ; i ++ ) { if ( ( c [ i ] - ' ' ) == 1 ) b += ' ' ; else b += ' ' ; } document . write ( parseInt ( b , 2 ) ) ; } var a = 4 ; maxValue ( a ) ;

Index/key variables: i
Accumulator variables: b, i
Iterator variables: i
Javascript program:
const sz = 100000 ; let isPrime = new Array ( sz + 1 ) . fill ( true ) ; function generatePrime ( ) { let i , j ; isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( i = 2 ; i * i <= sz ; i ++ ) { if ( isPrime [ i ] ) { for ( j = i * i ; j < sz ; j += i ) { isPrime [ j ] = false ; } } } } function Pair_of_PrimeXor ( A , n ) { for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { if ( isPrime [ ( A [ i ] ^ A [ j ] ) ] ) { document . write ( " " + A [ i ] + " " + A [ j ] + " " ) ; } } } } let A = [ 1 , 3 , 6 , 11 ] ; let n = A . length ; generatePrime ( ) ; Pair_of_PrimeXor ( A , n ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function getnumbers ( n ) { let divisor = [ ] ; for ( let i = 2 ; i * i <= n ; i ++ ) { while ( n % i == 0 ) { divisor . push ( i ) ; n = Math . floor ( n / i ) ; } } if ( n != 1 ) { divisor . push ( n ) ; } let a , b , c , size ; a = b = c = 1 ; size = divisor . length ; for ( let i = 0 ; i < size ; i ++ ) { if ( a == 1 ) { a = a * divisor [ i ] ; } else if ( b == 1 b == a ) { b = b * divisor [ i ] ; } else { c = c * divisor [ i ] ; } } if ( a == 1 b == 1 c == 1 a == b b == c a == c ) { document . write ( " " + " " ) ; } else { document . write ( a + " " + b + " " + c + " " ) ; } } let n = 64 ; getnumbers ( n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function primeFactors ( n ) { let i , j ; let Prime = new Array ( ) ; if ( n % 2 == 0 ) { Prime . push ( 2 ) ; } while ( n % 2 == 0 ) { n = n / 2 ; } for ( i = 3 ; i <= Math . sqrt ( n ) ; i = i + 2 ) { if ( n % i == 0 ) { Prime . push ( i ) ; } while ( n % i == 0 ) { n = n / i ; } } if ( n > 2 ) { Prime . push ( n ) ; } return Prime ; } function checkDistinctPrime ( n ) { let Prime = primeFactors ( n ) ; let product = 1 ; for ( let i of Prime ) { product *= i ; } if ( product == n ) document . write ( " " ) ; else document . write ( " " ) ; } let N = 30 ; checkDistinctPrime ( N ) ;

Accumulator variables: product
Iterator variables: i
Javascript program:
function isPrime ( n ) { for ( let i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { return false ; } } return true ; } function printMinCountPrime ( N ) { let minCount ; if ( isPrime ( N ) ) { minCount = 1 ; } else if ( N % 2 == 0 ) { minCount = 2 ; } else { if ( isPrime ( N - 2 ) ) { minCount = 2 ; } else { minCount = 3 ; } } document . write ( minCount + " " ) ; } let N = 100 ; printMinCountPrime ( N ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let INFINITY_ = 9999999 ; function sqrtByLongDivision ( n ) { let cur_divisor = 0 ; let quotient_units_digit = 0 ; let cur_quotient = 0 ; let cur_dividend = 0 ; let cur_remainder = 0 ; let a = new Array ( 10 ) ; while ( n > 0 ) { a [ i ] = n % 100 ; n = Math . floor ( n / 100 ) ; i ++ ; } i -- ; for ( j = i ; j >= 0 ; j -- ) { cur_remainder = INFINITY_ ; cur_dividend = cur_dividend * 100 + a [ j ] ; for ( udigit = 0 ; udigit <= 9 ; udigit ++ ) { if ( cur_remainder >= cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) && cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) >= 0 ) { cur_remainder = cur_dividend - ( ( cur_divisor * 10 + udigit ) * udigit ) ; quotient_units_digit = udigit ; } } cur_quotient = cur_quotient * 10 + quotient_units_digit ; cur_divisor = cur_quotient * 2 ; cur_dividend = cur_remainder ; } return cur_quotient ; } let x = 1225 ; document . write ( sqrtByLongDivision ( x ) + " " ) ;

Index/key variables: i, j
Accumulator variables: i, j, udigit
Iterator variables: j, udigit
Javascript program:
function previousFibonacci ( n ) { var a = n / ( ( 1 + Math . sqrt ( 5 ) ) / 2.0 ) ; return Math . round ( a ) ; } function nextFibonacci ( n ) { var a = n * ( 1 + Math . sqrt ( 5 ) ) / 2.0 ; return Math . round ( a ) ; } function isPerfectSquare ( x ) { var s = Math . sqrt ( x ) ; return ( s * s == x ) ; } function isFibonacci ( n ) { return ( isPerfectSquare ( 5 * n * n + 4 ) || isPerfectSquare ( 5 * n * n - 4 ) ) ; } function countFibonacciPairs ( arr , n ) { var res = 0 ; for ( var i = 0 ; i < n ; i ++ ) for ( var j = i + 1 ; j < n ; j ++ ) if ( isFibonacci ( arr [ i ] ) && isFibonacci ( arr [ j ] ) ) { var prevFib = previousFibonacci ( arr [ i ] ) ; var nextFib = nextFibonacci ( arr [ i ] ) ; if ( prevFib == arr [ j ] nextFib == arr [ j ] ) { res ++ ; } } return res ; } var a = [ 3 , 5 , 8 , 11 ] ; var n = a . length ; document . write ( countFibonacciPairs ( a , n ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Javascript program:
function countPairsWithProdK ( arr , n , k ) { var count = 0 ; for ( var i = 0 ; i < n ; i ++ ) { for ( var j = i + 1 ; j < n ; j ++ ) if ( arr [ i ] * arr [ j ] == k ) count ++ ; } return count ; } var arr = [ 1 , 5 , 3 , 4 , 2 ] ; var N = arr . length ; var K = 3 ; document . write ( countPairsWithProdK ( arr , N , K ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
let MAX = 100000 ; function countPairsWithProductK ( arr , n , k ) { let count = 0 ; let i ; let hashmap = new Array ( MAX ) ; for ( i = 0 ; i < n ; i ++ ) hashmap [ arr [ i ] ] = true ; for ( i = 0 ; i < n ; i ++ ) { let x = arr [ i ] ; let index = 1.0 * k / arr [ i ] ; if ( index >= 0 && ( ( index - Math . floor ( index ) ) == 0 ) && hashmap [ k / x ] ) count ++ ; hashmap [ x ] = false ; } return count ; } let arr = [ 1 , 5 , 3 , 4 , 2 ] ; let N = arr . length ; let K = 3 ; document . write ( countPairsWithProductK ( arr , N , K ) ) ;

Index/key variables: i, x
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function oddIntegers ( n , k ) { if ( n % 2 != k % 2 ) { document . write ( " " ) ; return ; } var sum = 0 ; var i = 1 ; var j = 1 ; while ( j < k ) { sum = sum + i ; document . write ( i + " " ) ; i = i + 2 ; j ++ ; } var finalOdd = n - sum ; document . write ( finalOdd ) ; } var n = 10 ; var k = 2 ; oddIntegers ( n , k ) ;

Accumulator variables: j
Javascript program:
function search ( a , k , x ) { var j ; for ( j = k - 1 ; j > - 1 ; j -- ) { if ( a [ j ] == x ) return j ; } return - 1 ; } function genArray ( arr , N ) { for ( var i = 0 ; i < N - 1 ; i ++ ) { if ( search ( arr , i , arr [ i ] ) == - 1 ) arr [ i + 1 ] = 0 ; else arr [ i + 1 ] = ( i - search ( arr , i , arr [ i ] ) ) ; } } var N = 5 ; var size = N + 1 ; var a = [ 0 , 0 , 0 , 0 , 0 ] ; genArray ( a , N ) ; document . write ( " " + a + " " ) ;

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