dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function gcd ( a , b ) { while ( b > 0 ) { let rem = a % b ; a = b ; b = rem ; } return a ; } function countNumberOfWays ( n ) { if ( n == 1 ) return - 1 ; let g = 0 ; let power = 0 ; while ( n % 2 == 0 ) { power ++ ; n /= 2 ; } g = gcd ( g , power ) ; for ( let i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { power = 0 ; while ( n % i == 0 ) { power ++ ; n /= i ; } g = gcd ( g , power ) ; } if ( n > 2 ) g = gcd ( g , 1 ) ; let ways = 1 ; power = 0 ; while ( g % 2 == 0 ) { g /= 2 ; power ++ ; } ways *= ( power + 1 ) ; for ( let i = 3 ; i <= Math . sqrt ( g ) ; i += 2 ) { power = 0 ; while ( g % i == 0 ) { power ++ ; g /= i ; } ways *= ( power + 1 ) ; } if ( g > 2 ) ways *= 2 ; return ways ; } let N = 64 ; document . write ( countNumberOfWays ( N ) ) ;

Accumulator variables: g, i, n, power, ways
Iterator variables: i
Javascript program:
function smallestPoss ( s , n ) { var ans = " " ; var arr = Array ( 10 ) . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) { arr [ s [ i ] . charCodeAt ( 0 ) - 48 ] ++ ; } for ( var i = 0 ; i < 10 ; i ++ ) { for ( var j = 0 ; j < arr [ i ] ; j ++ ) ans = ans + i . toString ( ) ; } return ans ; } var N = 15 ; var K = " " ; document . write ( smallestPoss ( K , N ) ) ;

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function Count_subarray ( arr , n ) { var subarray_sum , remaining_sum , count = 0 ; var i , j , k , l ; for ( i = 0 ; i < n ; i ++ ) { for ( j = i ; j < n ; j ++ ) { subarray_sum = 0 ; remaining_sum = 0 ; for ( k = i ; k <= j ; k ++ ) { subarray_sum += arr [ k ] ; } for ( l = 0 ; l < i ; l ++ ) { remaining_sum += arr [ l ] ; } for ( l = j + 1 ; l < n ; l ++ ) { remaining_sum += arr [ l ] ; } if ( subarray_sum > remaining_sum ) { count += 1 ; } } } return count ; } var arr = [ 10 , 9 , 12 , 6 ] ; var n = arr . length ; document . write ( Count_subarray ( arr , n ) ) ;

Index/key variables: k, l
Accumulator variables: count, i, j, k, l, remaining_sum, subarray_sum
Iterator variables: i, j, k, l
Javascript program:
function Count_subarray ( arr , n ) { var total_sum = 0 , subarray_sum , remaining_sum , count = 0 ; for ( i = 0 ; i < n ; i ++ ) { total_sum += arr [ i ] ; } for ( i = 0 ; i < n ; i ++ ) { subarray_sum = 0 ; for ( j = i ; j < n ; j ++ ) { subarray_sum += arr [ j ] ; remaining_sum = total_sum - subarray_sum ; if ( subarray_sum > remaining_sum ) { count += 1 ; } } } return count ; } var arr = [ 10 , 9 , 12 , 6 ] ; var n = arr . length ; document . write ( Count_subarray ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j, subarray_sum, total_sum
Iterator variables: i, j
Javascript program:
function maxXOR ( arr , n ) { let xorArr = 0 ; for ( let i = 0 ; i < n ; i ++ ) xorArr ^= arr [ i ] ; let ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) ans = Math . max ( ans , ( xorArr ^ arr [ i ] ) ) ; return ans ; } let arr = [ 1 , 1 , 3 ] ; let n = arr . length ; document . write ( maxXOR ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i, xorArr
Iterator variables: i
Javascript program:
function digitDividesK ( num , k ) { while ( num ) { let d = num % 10 ; if ( d != 0 && k % d == 0 ) return true ; num = parseInt ( num / 10 ) ; } return false ; } function findCount ( l , r , k ) { let count = 0 ; for ( let i = l ; i <= r ; i ++ ) { if ( digitDividesK ( i , k ) ) count ++ ; } return count ; } let l = 20 , r = 35 ; let k = 45 ; document . write ( findCount ( l , r , k ) ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function isFactorial ( n ) { for ( var i = 1 ; ; i ++ ) { if ( n % i == 0 ) { n = parseInt ( n / i ) ; } else { break ; } } if ( n == 1 ) { return true ; } else { return false ; } } var n = 24 ; var ans = isFactorial ( n ) ; if ( ans == 1 ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Accumulator variables: i
Iterator variables: i
Javascript program:
function lcm ( a , b ) { let GCD = __gcd ( a , b ) ; return Math . floor ( ( a * b ) / GCD ) ; } function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } function MinLCM ( a , n ) { let Prefix = new Array ( n + 2 ) ; let Suffix = new Array ( n + 2 ) ; Prefix [ 1 ] = a [ 0 ] ; for ( let i = 2 ; i <= n ; i += 1 ) { Prefix [ i ] = lcm ( Prefix [ i - 1 ] , a [ i - 1 ] ) ; } Suffix [ n ] = a [ n - 1 ] ; for ( let i = n - 1 ; i >= 1 ; i -= 1 ) { Suffix [ i ] = lcm ( Suffix [ i + 1 ] , a [ i - 1 ] ) ; } let ans = Math . min ( Suffix [ 2 ] , Prefix [ n - 1 ] ) ; for ( let i = 2 ; i < n ; i += 1 ) { ans = Math . min ( ans , lcm ( Prefix [ i - 1 ] , Suffix [ i + 1 ] ) ) ; } return ans ; } let a = [ 5 , 15 , 9 , 36 ] ; let n = a . length ; document . write ( MinLCM ( a , n ) ) ;

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Javascript program:
function findMinValue ( arr , n ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; return ( parseInt ( sum / n ) + 1 ) ; } let arr = [ 4 , 2 , 1 , 10 , 6 ] ; let n = arr . length ; document . write ( findMinValue ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
const MOD = 1000000007 ; function modFact ( n , m ) { let result = 1 ; for ( let i = 1 ; i <= m ; i ++ ) result = ( result * i ) % MOD ; return result ; } let n = 3 , m = 2 ; document . write ( modFact ( n , m ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
const mod = 1000000000 + 7 ; function power ( p ) { let res = 1 ; for ( let i = 1 ; i <= p ; ++ i ) { res *= 2 ; res %= mod ; } return res % mod ; } function subset_square_sum ( A ) { let n = A . length ; let ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) { ans += ( A [ i ] * A [ i ] ) % mod ; ans %= mod ; } return ( ans * power ( n - 1 ) ) % mod ; } let A = [ 3 , 7 ] ; document . write ( subset_square_sum ( A ) ) ;

Index/key variables: i
Accumulator variables: ans, i, res
Iterator variables: i
Javascript program:
var N = 100050 ; var lpf = Array ( N ) . fill ( 0 ) ; var mobius = Array ( N ) . fill ( 0 ) ; function least_prime_factor ( ) { for ( i = 2 ; i < N ; i ++ ) if ( lpf [ i ] == 0 ) for ( j = i ; j < N ; j += i ) if ( lpf [ j ] == 0 ) lpf [ j ] = i ; } function Mobius ( ) { for ( i = 1 ; i < N ; i ++ ) { if ( i == 1 ) mobius [ i ] = 1 ; else { if ( lpf [ i / lpf [ i ] ] == lpf [ i ] ) mobius [ i ] = 0 ; else mobius [ i ] = - 1 * mobius [ i / lpf [ i ] ] ; } } } function gcd_pairs ( a , n ) { var maxi = 0 ; var fre = Array ( n + 1 ) . fill ( 0 ) ; for ( i = 0 ; i < n ; i ++ ) { fre [ a [ i ] ] ++ ; maxi = Math . max ( a [ i ] , maxi ) ; } least_prime_factor ( ) ; Mobius ( ) ; var ans = 0 ; for ( i = 1 ; i <= maxi ; i ++ ) { if ( mobius [ i ] == 0 ) continue ; var temp = 0 ; for ( j = i ; j <= maxi ; j += i ) temp = parseInt ( temp + fre [ j ] ) ; ans += parseInt ( temp * ( temp - 1 ) / 2 * mobius [ i ] ) ; } return ans ; } var a = [ 1 , 2 , 3 , 4 , 5 , 6 ] ; var n = a . length ; document . write ( gcd_pairs ( a , n ) ) ;

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
function ZigZag ( n ) { var fact = Array ( n + 1 ) . fill ( 0 ) ; var zig = Array ( n + 1 ) . fill ( 0 ) ; fact [ 0 ] = 1 ; for ( var i = 1 ; i <= n ; i ++ ) fact [ i ] = fact [ i - 1 ] * i ; zig [ 0 ] = 1 ; zig [ 1 ] = 1 ; document . write ( " " ) ; document . write ( zig [ 0 ] + " " + zig [ 1 ] + " " ) ; for ( var i = 2 ; i < n ; i ++ ) { var sum = 0 ; for ( var k = 0 ; k <= i - 1 ; k ++ ) { sum += parseInt ( fact [ i - 1 ] / ( fact [ i - 1 - k ] * fact [ k ] ) ) * zig [ k ] * zig [ i - 1 - k ] ; } zig [ i ] = parseInt ( sum / 2 ) ; document . write ( parseInt ( sum / 2 ) + " " ) ; } } var n = 10 ; ZigZag ( n ) ;

Index/key variables: i, k
Accumulator variables: i, k, sum
Iterator variables: i, k
Javascript program:
function find_count ( ele ) { let count = 0 ; for ( let i = 0 ; i < ele . length ; i ++ ) { let p = [ ] ; let c = 0 ; for ( let j = ele . length - 1 ; j >= ( ele . length - 1 - i ) && j >= 0 ; j -- ) p . push ( ele [ j ] ) ; let j = ele . length - 1 , k = 0 ; while ( j >= 0 ) { if ( ele [ j ] != p [ k ] ) break ; j -- ; k ++ ; if ( k == p . length ) { c ++ ; k = 0 ; } } count = Math . max ( count , c ) ; } return count ; } function solve ( n ) { let count = 1 ; let ele = [ ] ; for ( let i = 0 ; i < n ; i ++ ) { document . write ( count + " " ) ; ele . push ( count ) ; count = find_count ( ele ) ; } } let n = 10 ; solve ( n ) ;

Index/key variables: j, k
Accumulator variables: c, i, j, k
Iterator variables: i, j
Javascript program:
var store = new Map ( ) ; function Wedderburn ( n ) { if ( n <= 2 ) return store [ n ] ; else if ( n % 2 == 0 ) { var x = parseInt ( n / 2 ) , ans = 0 ; for ( var i = 1 ; i < x ; i ++ ) { ans += store [ i ] * store [ n - i ] ; } ans += ( store [ x ] * ( store [ x ] + 1 ) ) / 2 ; store [ n ] = ans ; return ans ; } else { var x = ( n + 1 ) / 2 , ans = 0 ; for ( var i = 1 ; i < x ; i ++ ) { ans += store [ i ] * store [ n - i ] ; } store [ n ] = ans ; return ans ; } } function Wedderburn_Etherington ( n ) { store [ 0 ] = 0 ; store [ 1 ] = 1 ; store [ 2 ] = 1 ; for ( var i = 0 ; i < n ; i ++ ) { document . write ( Wedderburn ( i ) ) ; if ( i != n - 1 ) document . write ( " " ) ; } } var n = 10 ; Wedderburn_Etherington ( n ) ;

Index/key variables: i, n, x
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function Max_sum ( a , n ) { let pos = 0 , neg = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( a [ i ] > 0 ) pos = 1 ; else if ( a [ i ] < 0 ) neg = 1 ; if ( pos == 1 && neg == 1 ) break ; } let sum = 0 ; if ( pos == 1 && neg == 1 ) { for ( let i = 0 ; i < n ; i ++ ) sum += Math . abs ( a [ i ] ) ; } else if ( pos == 1 ) { let mini = a [ 0 ] ; sum = a [ 0 ] ; for ( let i = 1 ; i < n ; i ++ ) { mini = Math . min ( mini , a [ i ] ) ; sum += a [ i ] ; } sum -= 2 * mini ; } else if ( neg == 1 ) { for ( let i = 0 ; i < n ; i ++ ) a [ i ] = Math . abs ( a [ i ] ) ; let mini = a [ 0 ] ; sum = a [ 0 ] ; for ( let i = 1 ; i < n ; i ++ ) { mini = Math . min ( mini , a [ i ] ) ; sum += a [ i ] ; } sum -= 2 * mini ; } return sum ; } let a = [ 1 , 3 , 5 , - 2 , - 6 ] ; let n = a . length ; document . write ( Max_sum ( a , n ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function smallestIndex ( a , n ) { let right1 = 0 , right0 = 0 ; let i ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 1 ) right1 = i ; else right0 = i ; } return Math . min ( right1 , right0 ) ; } var a = [ 1 , 1 , 1 , 0 , 0 , 1 , 0 , 1 , 1 ] ; let n = a . length ; document . write ( smallestIndex ( a , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countSquares ( r , c , m ) { let squares = 0 ; for ( let i = 1 ; i <= 8 ; i ++ ) { for ( let j = 1 ; j <= 8 ; j ++ ) { if ( Math . max ( Math . abs ( i - r ) , Math . abs ( j - c ) ) <= m ) squares ++ ; } } return squares ; } let r = 4 , c = 4 , m = 1 ; document . write ( countSquares ( r , c , m ) ) ;

Accumulator variables: i, j, squares
Iterator variables: i, j
Javascript program:
function countQuadruples ( a , n ) { let mp = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) if ( mp . has ( a [ i ] ) ) { mp . set ( a [ i ] , mp . get ( a [ i ] ) + 1 ) ; } else { mp . set ( a [ i ] , 1 ) ; } let count = 0 ; for ( let j = 0 ; j < n ; j ++ ) { for ( let k = 0 ; k < n ; k ++ ) { if ( j == k ) continue ; mp . set ( a [ j ] , mp . get ( a [ j ] ) - 1 ) ; mp . set ( a [ k ] , mp . get ( a [ k ] ) - 1 ) ; let first = a [ j ] - ( a [ k ] - a [ j ] ) ; let fourth = ( a [ k ] * a [ k ] ) / a [ j ] ; if ( ( a [ k ] * a [ k ] ) % a [ j ] == 0 ) { if ( a [ j ] != a [ k ] ) { if ( mp . has ( first ) && mp . has ( fourth ) ) count += mp . get ( first ) * mp . get ( fourth ) ; } else if ( mp . has ( first ) && mp . has ( fourth ) ) count += mp . get ( first ) * ( mp . get ( fourth ) - 1 ) ; } if ( mp . has ( a [ j ] ) ) { mp . set ( a [ j ] , mp . get ( a [ j ] ) + 1 ) ; } else { mp . set ( a [ j ] , 1 ) ; } if ( mp . has ( a [ k ] ) ) { mp . set ( a [ k ] , mp . get ( a [ k ] ) + 1 ) ; } else { mp . set ( a [ k ] , 1 ) ; } } } return count ; } let a = [ 2 , 6 , 4 , 9 , 2 ] ; let n = a . length ; document . write ( countQuadruples ( a , n ) ) ;

Index/key variables: i, j, k
Accumulator variables: count, i, j, k
Iterator variables: i, j, k
Javascript program:
function countNumbers ( L , R , K ) { if ( K == 9 ) { K = 0 ; } var totalnumbers = R - L + 1 ; var factor9 = totalnumbers / 9 ; var rem = totalnumbers % 9 ; var ans = factor9 ; for ( var i = R ; i > R - rem ; i -- ) { var rem1 = i % 9 ; if ( rem1 == K ) { ans ++ ; } } return ans ; } var L = 10 ; var R = 22 ; var K = 3 ; document . write ( Math . round ( countNumbers ( L , R , K ) ) ) ;

Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function EvenSum ( A , index , value ) { A [ index ] = A [ index ] + value ; var sum = 0 ; for ( var i = 0 ; i < A . length ; i ++ ) if ( A [ i ] % 2 == 0 ) sum = sum + A [ i ] ; return sum ; } function BalanceArray ( A , Q ) { var ANS = [ ] ; var i , sum ; for ( i = 0 ; i < Q . length ; i ++ ) { var index = Q [ i ] [ 0 ] ; var value = Q [ i ] [ 1 ] ; sum = EvenSum ( A , index , value ) ; ANS . push ( sum ) ; } for ( i = 0 ; i < ANS . length ; i ++ ) document . write ( ANS [ i ] + " " ) ; } var A = [ 1 , 2 , 3 , 4 ] ; var Q = [ [ 0 , 1 ] , [ 1 , - 3 ] , [ 0 , - 4 ] , [ 3 , 2 ] ] ; BalanceArray ( A , Q ) ;

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Javascript program:
function BalanceArray ( A , Q ) { var ANS = [ ] ; var i , sum = 0 ; for ( i = 0 ; i < A . length ; i ++ ) if ( A [ i ] % 2 == 0 ) sum = sum + A [ i ] ; for ( i = 0 ; i < Q . length ; i ++ ) { var index = Q [ i ] [ 0 ] ; var value = Q [ i ] [ 1 ] ; if ( A [ index ] % 2 == 0 ) sum = sum - A [ index ] ; A [ index ] = A [ index ] + value ; if ( A [ index ] % 2 == 0 ) sum = sum + A [ index ] ; ANS . push ( sum ) ; } for ( i = 0 ; i < ANS . length ; i ++ ) document . write ( ANS [ i ] + " " ) ; } var A = [ 1 , 2 , 3 , 4 ] ; var Q = [ [ 0 , 1 ] , [ 1 , - 3 ] , [ 0 , - 4 ] , [ 3 , 2 ] ] ; BalanceArray ( A , Q ) ;

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Javascript program:
function Cycles ( N ) { var fact = 1 , result = 0 ; result = N - 1 ; var i = result ; while ( i > 0 ) { fact = fact * i ; i -- ; } return fact / 2 ; } var N = 5 ; var Number = Cycles ( N ) ; document . write ( " " + Number ) ;

Accumulator variables: i
Javascript program:
function digitWell ( n , m , k ) { var cnt = 0 ; while ( n > 0 ) { if ( n % 10 == m ) ++ cnt ; n = Math . floor ( n / 10 ) ; } if ( cnt == k ) return true ; else return false ; } function findInt ( n , m , k ) { var i = n + 1 ; while ( true ) { if ( digitWell ( i , m , k ) ) return i ; i ++ ; } } var n = 111 , m = 2 , k = 2 ; document . write ( findInt ( n , m , k ) ) ;

Accumulator variables: i
Javascript program:
function countOdd ( arr , n ) { var odd = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 1 ) odd ++ ; } return odd ; } function countValidPairs ( arr , n ) { var odd = countOdd ( arr , n ) ; return ( odd * ( odd - 1 ) ) / 2 ; } var arr = [ 1 , 2 , 3 , 4 , 5 ] ; var n = arr . length ; document . write ( countValidPairs ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i, odd
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } function lcmOfArray ( arr , n ) { if ( n < 1 ) return 0 ; let lcm = arr [ 0 ] ; for ( let i = 1 ; i < n ; i ++ ) lcm = parseInt ( ( lcm * arr [ i ] ) / gcd ( lcm , arr [ i ] ) ) ; return lcm ; } function minPerfectCube ( arr , n ) { let minPerfectCube ; let lcm = lcmOfArray ( arr , n ) ; minPerfectCube = lcm ; let cnt = 0 ; while ( lcm > 1 && lcm % 2 == 0 ) { cnt ++ ; lcm = parseInt ( lcm / 2 ) ; } if ( cnt % 3 == 2 ) minPerfectCube *= 2 ; else if ( cnt % 3 == 1 ) minPerfectCube *= 4 ; let i = 3 ; while ( lcm > 1 ) { cnt = 0 ; while ( lcm % i == 0 ) { cnt ++ ; lcm = parseInt ( lcm / i ) ; } if ( cnt % 3 == 1 ) minPerfectCube *= i * i ; else if ( cnt % 3 == 2 ) minPerfectCube *= i ; i += 2 ; } return minPerfectCube ; } let arr = [ 10 , 125 , 14 , 42 , 100 ] ; let n = arr . length ; document . write ( minPerfectCube ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: cnt, i, minPerfectCube
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 isStrongPrime ( n ) { if ( ! isPrime ( n ) n == 2 ) return false ; let previous_prime = n - 1 ; let next_prime = n + 1 ; while ( ! isPrime ( next_prime ) ) next_prime ++ ; while ( ! isPrime ( previous_prime ) ) previous_prime -- ; let mean = parseInt ( ( previous_prime + next_prime ) / 2 ) ; if ( n > mean ) return true ; else return false ; } let n = 11 ; if ( isStrongPrime ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: next_prime, previous_prime
Iterator variables: i
Javascript program:
function countDigitsToBeRemoved ( N , K ) { var s = N . toString ( ) ; var res = 0 ; var f_zero = 0 ; for ( var i = s . length - 1 ; i >= 0 ; i -- ) { if ( K === 0 ) return res ; if ( s [ i ] === " " ) { f_zero = 1 ; K -- ; } else res ++ ; } if ( K === 0 ) return res ; else if ( f_zero === 1 ) return s . length - 1 ; return - 1 ; } var N = 10904025 ; var K = 2 ; document . write ( countDigitsToBeRemoved ( N , K ) + " " ) ; N = 1000 ; K = 5 ; document . write ( countDigitsToBeRemoved ( N , K ) + " " ) ; N = 23985 ; K = 2 ; document . write ( countDigitsToBeRemoved ( N , K ) + " " ) ;

Index/key variables: i
Accumulator variables: K, i, res
Iterator variables: i
Javascript program:
function getSum ( a , n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; ++ i ) { sum += ( i / Math . pow ( a , i ) ) ; } return sum ; } let a = 3 , n = 3 ; document . write ( getSum ( a , n ) . toFixed ( 7 ) ) ;

Accumulator variables: sum
Iterator variables: i
Javascript program:
function largestPrimeFactor ( n ) { var max = - 1 ; while ( n % 2 == 0 ) { max = 2 ; } for ( var i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { while ( n % i == 0 ) { max = i ; n = n / i ; } } if ( n > 2 ) max = n ; return max ; } function checkUnusual ( n ) { var factor = largestPrimeFactor ( n ) ; if ( factor > Math . sqrt ( n ) ) { return true ; } else { return false ; } } var n = 14 ; if ( checkUnusual ( n ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Accumulator variables: i
Iterator variables: i
Javascript program:
function isHalfReducible ( arr , n , m ) { var frequencyHash = Array ( m + 1 ) . fill ( 0 ) ; var i ; for ( i = 0 ; i < n ; i ++ ) { frequencyHash [ arr [ i ] % ( m + 1 ) ] ++ ; } for ( i = 0 ; i <= m ; i ++ ) { if ( frequencyHash [ i ] >= n / 2 ) break ; } if ( i <= m ) document . write ( " " ) ; else document . write ( " " ) ; } var arr = [ 8 , 16 , 32 , 3 , 12 ] ; var n = arr . length ; var m = 7 ; isHalfReducible ( arr , n , m ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var arr = [ ] ; function generateDivisors ( n ) { for ( var i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) arr . push ( i ) ; { arr . push ( i ) ; arr . push ( n / i ) ; } } } } function harmonicMean ( n ) { generateDivisors ( n ) ; var sum = 0.0 ; var len = arr . length ; for ( var i = 0 ; i < len ; i ++ ) sum = sum + ( n / arr [ i ] ) ; sum = ( sum / n ) ; return ( arr . length / sum ) ; } function isOreNumber ( n ) { var mean = harmonicMean ( n ) ; if ( mean - parseInt ( mean ) == 0 ) return true ; else return false ; } var n = 28 ; if ( isOreNumber ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX = 10000 ; let s = new Set ( ) ; function SieveOfEratosthenes ( ) { let prime = new Array ( MAX ) ; for ( let i = 0 ; i < prime . length ; i ++ ) { prime [ i ] = true ; } prime [ 0 ] = false ; prime [ 1 ] = false ; for ( let p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] == true ) { for ( let i = p * 2 ; i < MAX ; i += p ) prime [ i ] = false ; } } let product = 1 ; for ( let p = 2 ; p < MAX ; p ++ ) { if ( prime [ p ] ) { product = product * p ; s . add ( product + 1 ) ; } } } function isEuclid ( n ) { if ( s . has ( n ) ) return true ; else return false ; } SieveOfEratosthenes ( ) ; let n = 31 ; if ( isEuclid ( n ) ) document . write ( " " ) ; else document . write ( " " ) ; n = 42 ; if ( isEuclid ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
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 ( var i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } function isPowerOfTwo ( n ) { return ( n != 0 ) && ( ( n & ( n - 1 ) ) == 0 ) ; } var n = 43 ; if ( isPrime ( n ) && ( isPowerOfTwo ( n * 3 - 1 ) ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Iterator variables: i
Javascript program:
function arePermutations ( a , b , n , m ) { let sum1 = 0 , sum2 = 0 , mul1 = 1 , mul2 = 1 ; for ( let i = 0 ; i < n ; i ++ ) { sum1 += a [ i ] ; mul1 *= a [ i ] ; } for ( let i = 0 ; i < m ; i ++ ) { sum2 += b [ i ] ; mul2 *= b [ i ] ; } return ( ( sum1 == sum2 ) && ( mul1 == mul2 ) ) ; } let a = [ 1 , 3 , 2 ] ; let b = [ 3 , 1 , 2 ] ; let n = a . length ; let m = b . length ; if ( arePermutations ( a , b , n , m ) == true ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i, mul1, mul2, sum1, sum2
Iterator variables: i
Javascript program:
function Time ( arr , n , Emptypipe ) { var fill = 0 ; for ( var i = 0 ; i < n ; i ++ ) fill += 1 / arr [ i ] ; fill = fill - ( 1 / Emptypipe ) ; return 1 / fill ; } var arr = [ 12 , 14 ] ; var Emptypipe = 30 ; var n = arr . length ; document . write ( Math . floor ( Time ( arr , n , Emptypipe ) ) + " " ) ;

Index/key variables: i
Accumulator variables: fill, i
Iterator variables: i
Javascript program:
function check ( n ) { let sum = 0 ; while ( n != 0 ) { sum += n % 10 ; n = Math . floor ( n / 10 ) ; } if ( sum % 7 == 0 ) return 1 ; else return 0 ; } let n = 25 ; ( check ( n ) == 1 ) ? document . write ( " " ) : document . write ( " " ) ;

Accumulator variables: sum
Javascript program:
let N = 1000005 ; 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 SumOfPrimeDivisors ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) { if ( n % i == 0 ) { if ( isPrime ( i ) ) sum += i ; } } return sum ; } let n = 60 ; document . write ( " " + SumOfPrimeDivisors ( n ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function Sum ( N ) { let SumOfPrimeDivisors = new Array ( N + 1 ) ; for ( let i = 0 ; i < SumOfPrimeDivisors . length ; i ++ ) { SumOfPrimeDivisors [ i ] = 0 ; } for ( let i = 2 ; i <= N ; ++ i ) { if ( SumOfPrimeDivisors [ i ] == 0 ) { for ( let j = i ; j <= N ; j += i ) { SumOfPrimeDivisors [ j ] += i ; } } } return SumOfPrimeDivisors [ N ] ; } let N = 60 ; document . write ( " " + " " + Sum ( N ) + " " ) ;

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