dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function findPowerOfP ( N , p ) { var count = 0 ; var r = p ; while ( r <= N ) { count += ( N / r ) ; r = r * p ; } return count ; } function primeFactorsofB ( B ) { var ans = [ ] ; for ( var i = 2 ; B != 1 ; i ++ ) { if ( B % i == 0 ) { var count = 0 ; while ( B % i == 0 ) { B = B / i ; count ++ ; } ans . push ( [ i , count ] ) ; } } return ans ; } function largestPowerOfB ( N , B ) { var vec = [ ] ; vec = primeFactorsofB ( B ) ; var ans = Number . MAX_VALUE ; for ( var i = 0 ; i < vec . length ; i ++ ) ans = Math . min ( ans , Math . floor ( findPowerOfP ( N , vec [ i ] [ 0 ] ) / vec [ i ] [ 1 ] ) ) ; return ans ; } document . write ( largestPowerOfB ( 5 , 2 ) + " " ) ; document . write ( largestPowerOfB ( 6 , 9 ) + " " ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function parity ( a ) { return a % 3 ; } function solve ( array , size ) { var operations = 0 ; for ( var i = 0 ; i < size - 1 ; i ++ ) { if ( parity ( array [ i ] ) == parity ( array [ i + 1 ] ) ) { operations ++ ; if ( i + 2 < size ) { var pari1 = parity ( array [ i ] ) ; var pari2 = parity ( array [ i + 2 ] ) ; if ( pari1 == pari2 ) { if ( pari1 == 0 ) array [ i + 1 ] = 1 ; else if ( pari1 == 1 ) array [ i + 1 ] = 0 ; else array [ i + 1 ] = 1 ; } else { if ( ( pari1 == 0 && pari2 == 1 ) || ( pari1 == 1 && pari2 == 0 ) ) array [ i + 1 ] = 2 ; if ( ( pari1 == 1 && pari2 == 2 ) || ( pari1 == 2 && pari2 == 1 ) ) array [ i + 1 ] = 0 ; if ( ( pari1 == 2 && pari2 == 0 ) || ( pari1 == 0 && pari2 == 2 ) ) array [ i + 1 ] = 1 ; } } } } return operations ; } var array = [ 2 , 1 , 3 , 0 ] ; var size = array . length ; document . write ( solve ( array , size ) ) ;

Index/key variables: i
Accumulator variables: i, operations
Iterator variables: i
Javascript program:
var n = 3 function findPrefixCount ( p_arr , arr ) { for ( var i = 0 ; i < n ; i ++ ) for ( var j = n - 1 ; j >= 0 ; j -- ) { if ( arr [ i ] [ j ] ) continue ; if ( j != n - 1 ) p_arr [ i ] [ j ] += p_arr [ i ] [ j + 1 ] ; p_arr [ i ] [ j ] += ( ! arr [ i ] [ j ] ) ; } } function matrixOrValueOne ( arr ) { var p_arr = Array . from ( Array ( n ) , ( ) => Array ( n ) . fill ( 0 ) ) ; findPrefixCount ( p_arr , arr ) ; var count_zero_submatrices = 0 ; for ( var j = 0 ; j < n ; j ++ ) { var i = n - 1 ; var q = [ ] ; var to_sum = 0 ; while ( i >= 0 ) { var c = 0 ; while ( q . length != 0 && q [ q . length - 1 ] [ 0 ] > p_arr [ i ] [ j ] ) { to_sum -= ( q [ q . length - 1 ] [ 1 ] + 1 ) * ( q [ q . length - 1 ] [ 0 ] - p_arr [ i ] [ j ] ) ; c += q [ q . length - 1 ] [ 1 ] + 1 ; q . pop ( ) ; } to_sum += p_arr [ i ] [ j ] ; count_zero_submatrices += to_sum ; q . push ( [ p_arr [ i ] [ j ] , c ] ) ; i -- ; } } return ( n * ( n + 1 ) * n * ( n + 1 ) ) / 4 - count_zero_submatrices ; } var arr = [ [ 0 , 0 , 0 ] , [ 0 , 1 , 0 ] , [ 0 , 0 , 0 ] ] ; document . write ( matrixOrValueOne ( arr ) ) ;

Index/key variables: i, j
Accumulator variables: c, count_zero_submatrices, i, j, to_sum
Iterator variables: i, j
Javascript program:
const n = 3 ; function submatrixXor ( arr ) { let ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { let top_left = ( i + 1 ) * ( j + 1 ) ; let bottom_right = ( n - i ) * ( n - j ) ; if ( ( top_left % 2 == 1 ) && ( bottom_right % 2 == 1 ) ) ans = ( ans ^ arr [ i ] [ j ] ) ; } } return ans ; } let arr = [ [ 6 , 7 , 13 ] , [ 8 , 3 , 4 ] , [ 9 , 7 , 6 ] ] ; document . write ( submatrixXor ( arr ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function findDigitalRoot ( num ) { var sum = Number . MAX_VALUE , tempNum = num ; while ( sum >= 10 ) { sum = 0 ; while ( tempNum > 0 ) { sum += tempNum % 10 ; tempNum = parseInt ( tempNum / 10 ) ; } tempNum = sum ; } return sum ; } function findAnswer ( X , N ) { var counter = 0 ; for ( var i = 1 ; counter < N ; ++ i ) { var digitalRoot = findDigitalRoot ( i ) ; if ( digitalRoot == X ) { counter += 1 ; } if ( counter == N ) { document . write ( i ) ; break ; } } } var X = 1 , N = 3 ; findAnswer ( X , N ) ;

Accumulator variables: counter, sum
Iterator variables: i
Javascript program:
function count ( N , K , R ) { var sum = 0 ; for ( i = 1 ; i <= N ; i ++ ) { if ( i % K == R ) sum += i ; } return sum ; } var N = 20 , K = 4 , R = 3 ; document . write ( count ( N , K , R ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function getCount ( a , b , c ) { let count = 0 ; for ( let i = 1 ; i <= 81 ; i ++ ) { let cr = b * Math . pow ( i , a ) + c ; let tmp = cr ; let sm = 0 ; while ( tmp != 0 ) { sm += tmp % 10 ; tmp = Math . floor ( tmp / 10 ) ; } if ( sm == i && cr < 1e9 ) count ++ ; } return count ; } let a = 3 , b = 2 , c = 8 ; document . write ( getCount ( a , b , c ) ) ;

Accumulator variables: count, i, sm
Iterator variables: i
Javascript program:
function isSpiltPossible ( n , a ) { let sum = 0 , c1 = 0 ; for ( let i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; if ( a [ i ] == 1 ) { c1 ++ ; } } if ( sum % 2 != 0 ) return false ; if ( ( sum / 2 ) % 2 == 0 ) return true ; if ( c1 > 0 ) return true ; else return false ; } let n = 3 ; let a = [ 1 , 1 , 2 ] ; if ( isSpiltPossible ( n , a ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: c1, i, sum
Iterator variables: i
Javascript program:
function Make_tree ( n , d , k ) { if ( d > n - 1 ) { document . write ( " " ) ; return ; } let deg = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { deg [ i ] = 0 ; } let ans = [ ] ; let q = new Set ( ) ; for ( let i = 0 ; i < d ; ++ i ) { ++ deg [ i ] ; ++ deg [ i + 1 ] ; if ( deg [ i ] > k deg [ i + 1 ] > k ) { document . write ( " " ) ; return ; } ans . push ( [ i , i + 1 ] ) ; } for ( let i = 1 ; i < d ; ++ i ) q . add ( [ Math . max ( i , d - i ) , i ] ) ; for ( let i = d + 1 ; i < n ; ++ i ) { let arr = Array . from ( q ) ; while ( q . size != 0 && deg [ arr [ 0 ] [ 1 ] ] == k ) q . delete ( arr [ 0 ] ) ; if ( q . size == 0 arr [ 0 ] [ 0 ] == d ) { document . write ( " " ) return ; } ++ deg [ i ] ; ++ deg [ arr [ 0 ] [ 1 ] ] ; ans . push ( [ i , arr [ 0 ] [ 1 ] ] ) ; q . add ( [ arr [ 0 ] [ 0 ] + 1 , i ] ) ; } for ( let i = 0 ; i < n - 1 ; ++ i ) document . write ( ( ans [ i ] [ 0 ] + 1 ) + " " + ( ans [ i ] [ 1 ] + 1 ) + " " ) ; } let n = 6 , d = 3 , k = 4 ; Make_tree ( n , d , k ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let n = 3 ; function matrixSum ( arr ) { let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) for ( let j = 0 ; j < n ; j ++ ) { let top_left = ( i + 1 ) * ( j + 1 ) ; let bottom_right = ( n - i ) * ( n - j ) ; sum += ( top_left * bottom_right * arr [ i ] [ j ] ) ; } return sum ; } let arr = [ [ 1 , 1 , 1 ] , [ 1 , 1 , 1 ] , [ 1 , 1 , 1 ] ] ; document . write ( matrixSum ( arr ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Javascript program:
function maxAND ( L , R ) { var maximum = L & R ; for ( var i = L ; i < R ; i ++ ) for ( var j = i + 1 ; j <= R ; j ++ ) maximum = Math . max ( maximum , ( i & j ) ) ; return maximum ; } var L = 1 , R = 632 ; document . write ( maxAND ( L , R ) ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function findCount ( arr , n ) { var countOdd = 0 ; for ( var i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 == 1 ) countOdd ++ ; if ( countOdd % 2 == 0 ) return 1 ; else return 0 ; } var arr = [ 1 , 2 , 3 , 5 , 1 ] ; var n = arr . length ; document . write ( findCount ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: countOdd, i
Iterator variables: i
Javascript program:
let N = 10005 ; let isprime = new Array ( N ) . fill ( true ) ; let can = new Array ( N ) . fill ( false ) ; function SieveOfEratosthenes ( ) { for ( let p = 2 ; p * p < N ; p ++ ) { if ( isprime [ p ] == true ) { for ( let i = p * p ; i < N ; i += p ) isprime [ i ] = false ; } } let primes = new Array ( ) ; for ( let i = 2 ; i < N ; i ++ ) if ( isprime [ i ] ) primes . push ( i ) ; return primes ; } function Prime_Numbers ( n ) { let primes = SieveOfEratosthenes ( ) ; for ( let i = 0 ; i < primes . length - 1 ; i ++ ) if ( primes [ i ] + primes [ i + 1 ] + 1 < N ) can [ primes [ i ] + primes [ i + 1 ] + 1 ] = true ; let ans = 0 ; for ( let i = 2 ; i <= n ; i ++ ) { if ( can [ i ] && isprime [ i ] ) { ans ++ ; } } return ans ; } let n = 50 ; document . write ( Prime_Numbers ( n ) ) ;

Index/key variables: i, p
Accumulator variables: ans, i, p
Iterator variables: i, p
Javascript program:
function findAndSum ( arr , n ) { var sum = 0 ; var mul = 1 ; for ( var i = 0 ; i < 30 ; i ++ ) { var count_on = 0 ; var l = 0 ; for ( var j = 0 ; j < n ; j ++ ) { if ( ( arr [ j ] & ( 1 << i ) ) > 0 ) if ( count_on ) l ++ ; else { count_on = 1 ; l ++ ; } else if ( count_on ) { sum += ( ( mul * l * ( l + 1 ) ) / 2 ) ; count_on = 0 ; l = 0 ; } } if ( count_on ) { sum += ( ( mul * l * ( l + 1 ) ) / 2 ) ; count_on = 0 ; l = 0 ; } mul *= 2 ; } return sum ; } var arr = [ 7 , 1 , 1 , 5 ] ; var n = arr . length ; document . write ( findAndSum ( arr , n ) ) ;

Index/key variables: j
Accumulator variables: i, j, l, mul, sum
Iterator variables: i, j
Javascript program:
function getPairs ( a ) { let count = 0 ; for ( let i = 0 ; i < a . length ; i ++ ) { for ( let j = 0 ; j < a . length ; j ++ ) { if ( a [ i ] < a [ j ] ) count ++ ; } } return count ; } let a = [ 2 , 4 , 3 , 1 ] ; document . write ( getPairs ( a ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function isComposite ( n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return false ; if ( n % 2 == 0 n % 3 == 0 ) return true ; for ( let i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } function isDigitSumOne ( nm ) { while ( nm > 9 ) { let sum_digit = 0 ; while ( nm > 0 ) { let digit = nm % 10 ; sum_digit = sum_digit + digit ; nm = Math . floor ( nm / 10 ) ; } nm = sum_digit ; } if ( nm == 1 ) return true ; else return false ; } function printValidNums ( l , r ) { for ( let i = l ; i <= r ; i ++ ) { if ( isComposite ( i ) && isDigitSumOne ( i ) ) document . write ( i + " " ) ; } } let l = 10 , r = 100 ; printValidNums ( l , r ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let mod = 1000000007 ; let arr = new Array ( 1000001 ) ; arr . fill ( 0 ) ; function cal_factorial ( ) { arr [ 0 ] = 1 ; for ( let i = 1 ; i <= 1000000 ; i ++ ) { arr [ i ] = ( ( arr [ i - 1 ] * i ) % mod ) ; } } function mod_exponent ( num , p ) { if ( p != 0 ) return 1 ; if ( ( p & 1 ) != 0 ) { return ( ( num % mod ) * ( mod_exponent ( ( num * num ) % mod , parseInt ( p / 2 , 10 ) ) ) % mod ) % mod ; } else return ( mod_exponent ( ( num * num ) % mod , parseInt ( p / 2 , 10 ) ) ) % mod ; } function getCount ( x , y ) { let ans = arr [ x + y - 1 ] ; ans *= 0 * mod_exponent ( arr [ x ] , mod - 2 ) ; ans ++ ; ans %= mod ; ans *= mod_exponent ( arr [ y ] , mod - 2 ) ; ans %= mod ; ans *= ( x - y ) ; ans %= mod ; return ans ; } cal_factorial ( ) ; let x = 3 , y = 1 ; document . write ( getCount ( x , y ) ) ;

Index/key variables: i, x, y
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function countTriplets ( n , points ) { var pts = new Set ( ) ; var ct = 0 ; for ( var i = 0 ; i < n ; i ++ ) pts . add ( points [ i ] . toString ( ) ) ; for ( var i = 0 ; i < n ; i ++ ) for ( var j = i + 1 ; j < n ; j ++ ) { var x = points [ i ] [ 0 ] + points [ j ] [ 0 ] ; var y = points [ i ] [ 1 ] + points [ j ] [ 1 ] ; if ( x % 2 == 0 && y % 2 == 0 ) if ( pts . has ( [ ( x / 2 ) , ( y / 2 ) ] . toString ( ) ) ) ct ++ ; } return ct ; } var points = [ [ 1 , 1 ] , [ 2 , 2 ] , [ 3 , 3 ] ] ; var n = points . length ; document . write ( countTriplets ( n , points ) )

Index/key variables: i, j
Accumulator variables: ct, i, j
Iterator variables: i, j
Javascript program:
function mixtureConcentration ( n , p ) { var res = 0 ; for ( var i = 0 ; i < n ; i ++ ) res += p [ i ] ; res /= n ; return res ; } var arr = [ 0 , 20 , 20 ] ; var n = arr . length ; document . write ( mixtureConcentration ( n , arr ) . toFixed ( 4 ) ) ;

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Javascript program:
const MAX = ( 5 ) ; let MOD = ( 7 ) ; function check ( num , a , b ) { while ( num > 0 ) { var rem = num % 10 ; num = parseInt ( num / 10 ) ; if ( rem != a && rem != b ) return false ; } return true ; } function power ( x , y ) { var ans = 1 ; while ( y > 0 ) { if ( ( y & 1 ) > 0 ) ans = ( ans * x ) % MOD ; y >>= 1 ; x = ( x * x ) % MOD ; } return ans % MOD ; } function modInverse ( x ) { return power ( x , MOD - 2 ) ; } function countNumbers ( n , a , b ) { var fact = Array ( MAX ) . fill ( 0 ) ; var inv = Array ( MAX ) . fill ( 0 ) ; var ans = 0 ; fact [ 0 ] = 1 ; for ( var i = 1 ; i < MAX ; i ++ ) { fact [ i ] = ( 1 * fact [ i - 1 ] * i ) ; fact [ i ] %= MOD ; } inv [ MAX - 1 ] = modInverse ( fact [ MAX - 1 ] ) ; for ( i = MAX - 2 ; i >= 0 ; i -- ) { inv [ i ] = ( inv [ i + 1 ] * ( i + 1 ) ) ; inv [ i ] %= MOD ; } if ( a < b ) { var x = a ; a = b ; b = x ; } for ( s = n ; s <= 9 * n ; s ++ ) { if ( ! check ( s , a , b ) ) continue ; if ( s < n * b || ( s - n * b ) % ( a - b ) != 0 ) continue ; var numDig = parseInt ( ( ( s - n * b ) / ( a - b ) ) ) ; if ( numDig > n ) continue ; var curr = fact [ parseInt ( n ) ] ; curr = ( curr * inv [ numDig ] ) % MOD ; curr = ( curr * inv [ parseInt ( n - numDig ) ] ) % MOD ; ans = ( ans + curr ) % MOD ; } return ans ; } var n = 3 , a = 1 , b = 3 ; document . write ( countNumbers ( n , a , b ) ) ;

Index/key variables: i, numDig
Accumulator variables: i, s
Iterator variables: i, s
Javascript program:
function checkTriangularSumRepresentation ( n ) { var tri = new Set ( ) ; var i = 1 ; while ( 1 ) { var x = i * parseInt ( ( i + 1 ) / 2 ) ; if ( x >= n ) break ; tri . add ( x ) ; i ++ ; } var ans = false ; tri . forEach ( tm => { if ( tri . has ( n - tm ) ) ans = true } ) ; return ans ; } var n = 24 ; checkTriangularSumRepresentation ( n ) ? document . write ( " " ) : document . write ( " " ) ;

Accumulator variables: i
Boolean variables: ans
Javascript program:
function digitsCount ( n ) { let len = 0 ; while ( n > 0 ) { len ++ ; n = Math . floor ( n / 10 ) ; } return len ; } function absoluteFirstLast ( n , x ) { let i = 0 , mod = 1 ; while ( i < x ) { mod *= 10 ; i ++ ; } let last = n % mod ; let len = digitsCount ( n ) ; while ( len != x ) { n = Math . floor ( n / 10 ) ; len -- ; } let first = n ; return Math . abs ( first - last ) ; } let n = 21546 , x = 2 ; document . write ( absoluteFirstLast ( n , x ) ) ;

Accumulator variables: i, len, mod
Javascript program:
function make_sequence ( N ) { var arr = Array ( N + 1 ) , sum = 0 ; for ( var i = 1 ; i <= N ; i ++ ) { if ( i % 2 == 1 ) arr [ i ] = 1 ; else arr [ i ] = 2 ; sum += arr [ i ] ; } if ( sum % 2 == 1 ) arr [ 2 ] = 3 ; for ( var i = 1 ; i <= N ; i ++ ) document . write ( arr [ i ] + " " ) ; } var N = 9 ; make_sequence ( N ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function countOdd ( L , R ) { let N = Math . floor ( ( R - L ) / 2 ) ; if ( R % 2 != 0 L % 2 != 0 ) N += 1 ; return N ; } let L = 3 , R = 7 ; let odds = countOdd ( L , R ) ; let evens = ( R - L + 1 ) - odds ; document . write ( " " + odds + " " ) ; document . write ( " " + evens + " " ) ;

Accumulator variables: N
Javascript program:
function minOperation ( n , k , a ) { for ( i = k ; i < n ; i ++ ) { if ( a [ i ] != a [ k - 1 ] ) document . write ( - 1 ) ; } for ( i = k - 2 ; i > - 1 ; i -- ) { if ( a [ i ] != a [ k - 1 ] ) document . write ( i + 1 ) ; } } var n = 5 ; var k = 3 ; var a = [ 2 , 1 , 1 , 1 , 1 ] ; minOperation ( n , k , a ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function binomialCoeff ( n , k ) { if ( k > n ) return 0 ; 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 ; } var N = 5 , M = 1 ; var P = ( N * ( N - 1 ) ) / 2 ; document . write ( binomialCoeff ( P , M ) ) ;

Accumulator variables: res
Iterator variables: i
Javascript program:
function generateSequence ( n , g ) { for ( var i = 1 ; i <= n ; i ++ ) { document . write ( i * g + " " ) ; } } var n = 6 , g = 5 ; generateSequence ( n , g ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX = 1000 ; let f = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { f [ i ] = 0 ; } function fib ( n ) { if ( n == 0 ) return 0 ; if ( n == 1 n == 2 ) return ( f [ n ] = 1 ) ; if ( f [ n ] != 0 ) return f [ n ] ; let k = 0 ; if ( ( n & 1 ) != 0 ) k = ( n + 1 ) / 2 ; else k = n / 2 ; if ( ( n & 1 ) != 0 ) f [ n ] = ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) ) ; else f [ n ] = ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) ; return f [ n ] ; } function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function findLCMFibonacci ( a , b ) { return ( fib ( a ) * fib ( b ) ) / fib ( gcd ( a , b ) ) ; } let a = 3 , b = 12 ; document . write ( findLCMFibonacci ( a , b ) ) ;

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Javascript program:
function isEvenOrOdd ( L , R ) { let oddCount = Math . floor ( ( R - L ) / 2 ) ; if ( R % 2 == 1 L % 2 == 1 ) oddCount ++ ; if ( oddCount % 2 == 0 ) return " " ; else return " " ; } let L = 5 , R = 15 ; document . write ( isEvenOrOdd ( L , R ) ) ;

Accumulator variables: oddCount
Javascript program:
function trailing_zeros ( N ) { let count_of_two = 0 , count_of_five = 0 ; for ( let i = 1 ; i <= N ; i ++ ) { let val = i ; while ( val % 2 == 0 && val > 0 ) { val = parseInt ( val / 2 ) ; count_of_two += i ; } while ( val % 5 == 0 && val > 0 ) { val = parseInt ( val / 5 ) ; count_of_five += i ; } } let ans = Math . min ( count_of_two , count_of_five ) ; return ans ; } let N = 12 ; document . write ( trailing_zeros ( N ) ) ;

Accumulator variables: count_of_five, count_of_two, i
Iterator variables: i
Javascript program:
let limit = 1000000000 let MAX_PRIME = 2000000 let MAX = 1000000 let I_MAX = 50000 let mp = new Map ( ) ; let b = new Array ( MAX ) ; let p = new Array ( MAX ) ; let j = 0 ; let prime = new Array ( MAX_PRIME + 1 ) ; function SieveOfEratosthenes ( n ) { prime . fill ( true ) ; for ( let p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( let i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } for ( let p = 2 ; p <= n ; p ++ ) { if ( prime [ p ] ) { b [ j ++ ] = p ; } } } function gcd ( a , b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } function printSeries ( n ) { SieveOfEratosthenes ( MAX_PRIME ) ; let i , g , k , l , m , d ; let ar = new Array ( I_MAX + 2 ) ; for ( i = 0 ; i < j ; i ++ ) { if ( ( b [ i ] * b [ i + 1 ] ) > limit ) break ; p [ i ] = b [ i ] ; mp [ b [ i ] * b [ i + 1 ] ] = 1 ; } d = 550 ; let flag = false ; for ( k = 2 ; ( k < d - 1 ) && ! flag ; k ++ ) { for ( m = 2 ; ( m < d ) && ! flag ; m ++ ) { for ( l = m + k ; l < d ; l += k ) { if ( ( ( b [ l ] * b [ l + k ] ) < limit ) && ( l + k ) < d && p [ i - 1 ] != b [ l + k ] && p [ i - 1 ] != b [ l ] && mp [ b [ l ] * b [ l + k ] ] != 1 ) { if ( mp [ p [ i - 1 ] * b [ l ] ] != 1 ) { p [ i ] = b [ l ] ; mp [ p [ i - 1 ] * b [ l ] ] = 1 ; i ++ ; } } if ( i >= I_MAX ) { flag = true ; break ; } } } } for ( i = 0 ; i < n ; i ++ ) ar [ i ] = p [ i ] * p [ i + 1 ] ; for ( i = 0 ; i < n - 1 ; i ++ ) document . write ( ar [ i ] + " " ) ; g = gcd ( ar [ n - 1 ] , ar [ n - 2 ] ) ; document . write ( g * 2 + " " ) ; } let n = 4 ; printSeries ( n ) ;

Index/key variables: i, l, p
Accumulator variables: i, j, k, l, m, p
Iterator variables: i, k, l, m, p
Boolean variables: flag
Javascript program:
let MAX = 620000 ; let prime = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { prime [ i ] = 0 ; } function Sieve ( ) { for ( let i = 2 ; i < MAX ; i ++ ) { if ( prime [ i ] == 0 ) { for ( let j = 2 * i ; j < MAX ; j += i ) { prime [ j ] = 1 ; } } } } function printSequence ( n ) { Sieve ( ) ; let v = [ ] ; let u = [ ] ; for ( let i = 13 ; i < MAX ; i ++ ) { if ( prime [ i ] == 0 ) { v . push ( i ) ; } } if ( n == 3 ) { document . write ( 6 + " " + 10 + " " + 15 ) ; return ; } let k ; for ( k = 0 ; k < n - 2 ; k ++ ) { if ( k % 3 == 0 ) { u . push ( v [ k ] * 6 ) ; } else if ( k % 3 == 1 ) { u . push ( v [ k ] * 15 ) ; } else { u . push ( v [ k ] * 10 ) ; } } k -- ; u . push ( v [ k ] * 7 ) ; u . push ( 7 * 11 ) ; u [ 0 ] = u [ 0 ] * 11 ; for ( let i = 0 ; i < u . length ; i ++ ) { document . write ( u [ i ] + " " ) ; } } let n = 4 ; printSequence ( n ) ;

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Javascript program:
function midptellipse ( rx , ry , xc , yc ) { var dx , dy , d1 , d2 , x , y ; x = 0 ; y = ry ; d1 = ( ry * ry ) - ( rx * rx * ry ) + ( 0.25 * rx * rx ) ; dx = 2 * ry * ry * x ; dy = 2 * rx * rx * y ; while ( dx < dy ) { document . write ( " " + ( x + xc ) . toFixed ( 5 ) + " " + ( y + yc ) . toFixed ( 5 ) + " " + " " ) ; document . write ( " " + ( - x + xc ) . toFixed ( 5 ) + " " + ( y + yc ) . toFixed ( 5 ) + " " + " " ) ; document . write ( " " + ( x + xc ) . toFixed ( 5 ) + " " + ( - y + yc ) . toFixed ( 5 ) + " " + " " ) ; document . write ( " " + ( - x + xc ) . toFixed ( 5 ) + " " + ( - y + yc ) . toFixed ( 5 ) + " " + " " ) ; if ( d1 < 0 ) { x ++ ; dx = dx + ( 2 * ry * ry ) ; d1 = d1 + dx + ( ry * ry ) ; } else { x ++ ; y -- ; dx = dx + ( 2 * ry * ry ) ; dy = dy - ( 2 * rx * rx ) ; d1 = d1 + dx - dy + ( ry * ry ) ; } } d2 = ( ( ry * ry ) * ( ( x + 0.5 ) * ( x + 0.5 ) ) ) + ( ( rx * rx ) * ( ( y - 1 ) * ( y - 1 ) ) ) - ( rx * rx * ry * ry ) ; while ( y >= 0 ) { document . write ( " " + ( x + xc ) . toFixed ( 5 ) + " " + ( y + yc ) . toFixed ( 5 ) + " " + " " ) ; document . write ( " " + ( - x + xc ) . toFixed ( 5 ) + " " + ( y + yc ) . toFixed ( 5 ) + " " + " " ) ; document . write ( " " + ( x + xc ) . toFixed ( 5 ) + " " + ( - y + yc ) . toFixed ( 5 ) + " " + " " ) ; document . write ( " " + ( - x + xc ) . toFixed ( 5 ) + " " + ( - y + yc ) . toFixed ( 5 ) + " " + " " ) ; if ( d2 > 0 ) { y -- ; dy = dy - ( 2 * rx * rx ) ; d2 = d2 + ( rx * rx ) - dy ; } else { y -- ; x ++ ; dx = dx + ( 2 * ry * ry ) ; dy = dy - ( 2 * rx * rx ) ; d2 = d2 + dx - dy + ( rx * rx ) ; } } } midptellipse ( 10 , 15 , 50 , 50 ) ;

Accumulator variables: x, y
Javascript program:
function isDivisible ( n ) { temp = n ; sum = 0 ; while ( n ) { k = n % 10 ; sum += k ; n = parseInt ( n / 10 ) ; } if ( temp % sum == 0 ) return " " ; return " " ; } let n = 123 ; document . write ( isDivisible ( n ) ) ;

Accumulator variables: sum
Javascript program:
function getResult ( n ) { let st = ( n ) . toString ( ) ; let sum = 0 ; for ( let i of st . split ( " " ) ) { sum = sum + parseInt ( i ) ; } if ( n % sum == 0 ) return " " ; else return " " ; } let n = 123 ; document . write ( getResult ( n ) + " " ) ;

Iterator variables: i
Javascript program:
function digitProduct ( n ) { let prod = 1 ; while ( n > 0 ) { prod = prod * ( n % 10 ) ; n = Math . floor ( n / 10 ) ; } return prod ; } function printMultiplicativePrimes ( n ) { let prime = new Array ( n + 1 ) ; for ( let i = 0 ; i <= n ; i ++ ) prime [ i ] = true ; prime [ 0 ] = prime [ 1 ] = false ; for ( let p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] ) { for ( let i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } for ( let i = 2 ; i <= n ; i ++ ) { if ( prime [ i ] && prime [ digitProduct ( i ) ] ) document . write ( i + " " ) ; } } let n = 10 ; printMultiplicativePrimes ( n ) ;

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Javascript program:
function gcd ( a , b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } function coPrime ( n1 , n2 ) { if ( gcd ( n1 , n2 ) == 1 ) return true ; else return false ; } function largestCoprime ( N ) { let half = Math . floor ( N / 2 ) ; while ( coPrime ( N , half ) == false ) half -- ; return half ; } let n = 50 ; document . write ( largestCoprime ( n ) ) ;

Accumulator variables: half