dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
var MAX = 100 ; function findNature ( a , b , n ) { var seq = Array ( MAX ) . fill ( 0 ) ; seq [ 0 ] = a ; seq [ 1 ] = b ; for ( var i = 2 ; i <= n ; i ++ ) seq [ i ] = seq [ i - 1 ] + seq [ i - 2 ] ; return ( seq [ n ] & 1 ) ; } var a = 2 , b = 4 ; var n = 3 ; ( findNature ( a , b , n ) ? ( document . write ( " " + " " ) ) : ( document . write ( " " + " " ) ) ) ;

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } function maxDivisorRange ( a , b , l , h ) { var g = gcd ( a , b ) ; var res = - 1 ; for ( i = l ; i * i <= g && i <= h ; i ++ ) if ( g % i == 0 ) res = Math . max ( res , Math . max ( i , g / i ) ) ; return res ; } var a = 3 , b = 27 , l = 1 , h = 5 ; document . write ( maxDivisorRange ( a , b , l , h ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function checksum ( n ) { if ( n == 0 ) { document . write ( " " ) ; return ; } var inc ; if ( n > 0 ) inc = 1 ; else inc = - 1 ; for ( i = 0 ; i <= n - 4 ; i += inc ) { if ( i + i + 1 + i + 2 + i + 3 + i + 4 == n ) { document . write ( ( i ) + " " + ( i + 1 ) + " " + ( i + 2 ) + " " + ( i + 3 ) + " " + ( i + 4 ) ) ; return ; } } document . write ( " " ) ; } var n = 15 ; checksum ( n ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let N = 1000001 var visited = new Array ( N ) ; var goesTo = new Array ( N ) ; function dfs ( i ) { if ( visited [ i ] == 1 ) return 0 ; visited [ i ] = 1 ; let x = dfs ( goesTo [ i ] ) ; return ( x + 1 ) ; } function noOfTranspositions ( P , n ) { for ( let i = 1 ; i <= n ; i ++ ) visited [ i ] = 0 ; for ( let i = 0 ; i < n ; i ++ ) goesTo [ P [ i ] ] = i + 1 ; let transpositions = 0 ; for ( let i = 1 ; i <= n ; i ++ ) { if ( visited [ i ] == 0 ) { let ans = dfs ( i ) ; transpositions += ans - 1 ; } } return transpositions ; } let permutation = [ 5 , 1 , 4 , 3 , 2 ] ; let n = permutation . length ; document . write ( noOfTranspositions ( permutation , n ) ) ;

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

Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function factorial ( n ) { let res = 1 ; for ( let i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } function calculateSeries ( n ) { return factorial ( n + 1 ) - 1 ; } let n = 3 ; document . write ( calculateSeries ( n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function factorial ( n ) { let res = 1 ; for ( let i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } function calculateSeries ( n ) { return 2 + ( n * n + n - 2 ) * factorial ( n + 1 ) ; } let n = 3 ; document . write ( calculateSeries ( n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function checkHankelMatrix ( n , m ) { for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { if ( i + j < n ) { if ( m [ i ] [ j ] != m [ i + j ] [ 0 ] ) return false ; } else { if ( m [ i ] [ j ] != m [ i + j - n + 1 ] [ n - 1 ] ) return false ; } } } return true ; } let n = 4 ; let m = [ [ 1 , 2 , 3 , 5 ] , [ 2 , 3 , 5 , 8 ] , [ 3 , 5 , 8 , 0 ] , [ 5 , 8 , 0 , 9 ] ] ; if ( checkHankelMatrix ( n , m ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isPower ( n ) { for ( x = 2 ; x <= parseInt ( Math . sqrt ( n ) ) ; x ++ ) { var f = Math . log ( n ) / Math . log ( x ) ; if ( ( f - parseInt ( f ) ) == 0.0 ) return true ; } return false ; } for ( i = 2 ; i < 100 ; i ++ ) if ( isPower ( i ) ) document . write ( i + " " ) ;

Accumulator variables: i, x
Iterator variables: i, x
Javascript program:
var N = 1000005 ; function sumOddDigit ( digitSum ) { for ( var i = 1 ; i < N ; i ++ ) { digitSum [ i ] = digitSum [ parseInt ( i / 10 ) ] + ( i & 1 ) * ( i % 10 ) ; } } function sumFactor ( digitSum , factorDigitSum ) { for ( var i = 1 ; i < N ; i ++ ) { for ( var j = i ; j < N ; j += i ) { factorDigitSum [ j ] += digitSum [ i ] ; } } } function wrapper ( q , n ) { var digitSum = Array ( N ) . fill ( 0 ) ; var factorDigitSum = Array ( N ) . fill ( 0 ) ; sumOddDigit ( digitSum ) ; sumFactor ( digitSum , factorDigitSum ) ; for ( var i = 0 ; i < q ; i ++ ) document . write ( factorDigitSum [ n [ i ] ] + " " ) ; } var q = 2 ; var n = [ 10 , 36 ] ; wrapper ( q , n ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let M = 10 ; function PrintMatrix ( a , n ) { for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j <= n ; j ++ ) document . write ( a [ i ] [ j ] + " " ) ; document . write ( " " ) ; } } function PerformOperation ( a , n ) { let i , j , k = 0 , c , flag = 0 , m = 0 ; let pro = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] [ i ] == 0 ) { c = 1 ; while ( ( i + c ) < n && a [ i + c ] [ i ] == 0 ) c ++ ; if ( ( i + c ) == n ) { flag = 1 ; break ; } for ( j = i , k = 0 ; k <= n ; k ++ ) { let temp = a [ j ] [ k ] ; a [ j ] [ k ] = a [ j + c ] [ k ] ; a [ j + c ] [ k ] = temp ; } } for ( j = 0 ; j < n ; j ++ ) { if ( i != j ) { let p = a [ j ] [ i ] / a [ i ] [ i ] ; for ( k = 0 ; k <= n ; k ++ ) a [ j ] [ k ] = a [ j ] [ k ] - ( a [ i ] [ k ] ) * p ; } } } return flag ; } function PrintResult ( a , n , flag ) { document . write ( " " ) ; if ( flag == 2 ) document . write ( " " ) ; else if ( flag == 3 ) document . write ( " " ) ; else { for ( let i = 0 ; i < n ; i ++ ) document . write ( a [ i ] [ n ] / a [ i ] [ i ] + " " ) ; } } function CheckConsistency ( a , n , flag ) { let i , j ; let sum ; flag = 3 ; for ( i = 0 ; i < n ; i ++ ) { sum = 0 ; for ( j = 0 ; j < n ; j ++ ) sum = sum + a [ i ] [ j ] ; if ( sum == a [ i ] [ j ] ) flag = 2 ; } return flag ; } let a = [ [ 0 , 2 , 1 , 4 ] , [ 1 , 1 , 2 , 6 ] , [ 2 , 1 , 1 , 7 ] ] ; let n = 3 , flag = 0 ; flag = PerformOperation ( a , n ) ; if ( flag == 1 ) flag = CheckConsistency ( a , n , flag ) ; document . write ( " " ) ; PrintMatrix ( a , n ) ; document . write ( " " ) ; PrintResult ( a , n , flag ) ;

Index/key variables: i, j, k, n
Accumulator variables: c, i, j, k
Iterator variables: i, j, k
Javascript program:
function number_of_digits ( n ) { let i , res , sum = 0 ; for ( i = 4 , res = 1 ; ; i *= 4 , res ++ ) { sum += i ; if ( sum >= n ) break ; } return res ; } let n = 21 ; document . write ( number_of_digits ( n ) + " " ) ;

Accumulator variables: i, res, sum
Iterator variables: i
Javascript program:
function Reverseorder ( n ) { let prime = new Array ( n + 1 ) ; for ( let i = 0 ; i < n ; i ++ ) prime [ i ] = true ; for ( let p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( let i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } for ( let p = n ; p >= 2 ; p -- ) if ( prime [ p ] ) document . write ( p + " " ) ; } let N = 25 ; document . write ( " " + " " ) ; if ( N == 1 ) document . write ( " " ) ; else

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Javascript program:
function checkVantieghemsTheorem ( limit ) { let prod = 1 ; for ( let n = 2 ; n < limit ; n ++ ) { if ( n == 2 ) document . write ( 2 + " " + " " ) ; if ( ( ( prod - n ) % ( ( 1 << n ) - 1 ) ) == 0 ) document . write ( n + " " + " " ) ; prod *= ( ( 1 << n ) - 1 ) ; } } checkVantieghemsTheorem ( 10 ) ;

Accumulator variables: n, prod
Iterator variables: n
Javascript program:
function magicOfSequence ( N ) { let sum = 0 ; for ( let i = 1 ; i <= N ; i ++ ) sum += ( i * i * i + i * 2 ) ; return sum ; } let N = 4 ; document . write ( magicOfSequence ( N ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function isPossibleToZero ( a , n ) { let even = 0 , odd = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( ( i & 1 ) == 0 ) odd += a [ i ] ; else even += a [ i ] ; } return ( odd == even ) ; } 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: even, i, odd
Iterator variables: i
Javascript program:
const PI = 3.142 ; function cosXSertiesSum ( x , n ) { x = x * ( PI / 180.0 ) ; let res = 1 ; let sign = 1 , fact = 1 , pow = 1 , i ; for ( i = 1 ; i < 5 ; i ++ ) { sign = sign * - 1 ; fact = fact * ( 2 * i - 1 ) * ( 2 * i ) ; pow = pow * x * x ; res = res + sign * pow / fact ; } return res ; } let x = 50 ; let n = 5 ; document . write ( ( ( cosXSertiesSum ( x , 5 ) * 1000000 ) / 1000000.00 ) . toFixed ( 6 ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function solve ( n , base ) { var result = 0 ; while ( n > 0 ) { var remainder = n % base ; result = result + remainder ; n = parseInt ( n / base ) ; } return result ; } function printSumsOfDigits ( n ) { for ( base = 2 ; base < n ; ++ base ) document . write ( solve ( n , base ) + " " ) ; } var n = 8 ; printSumsOfDigits ( n ) ;

Iterator variables: base
Javascript program:
function perfectSquare ( s ) { let n = s . length ; let ans = - 1 ; let num = " " ; for ( let i = 1 ; i < ( 1 << n ) ; i ++ ) { let str = " " ; for ( j = 0 ; j < n ; j ++ ) { if ( ( i >> j ) & 1 ) { str = str + s [ j ] ; } } if ( str [ 0 ] != ' ' ) { let temp = 0 ; for ( let j = 0 ; j < str . length ; j ++ ) temp = temp * 10 + ( str [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; k = Math . floor ( Math . sqrt ( temp ) ) ; if ( ( k * k ) == temp ) { if ( ans < str . length ) { ans = str . length ; num = str ; } } } } if ( ans == - 1 ) return ans ; else { document . write ( num + " " ) ; return ( n - ans ) ; } } document . write ( perfectSquare ( " " ) + " " ) ; document . write ( perfectSquare ( " " ) + " " ) ;

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function printFourSquares ( a ) { for ( let i = 0 ; i * i <= a ; i ++ ) { for ( let j = i ; j * j <= a ; j ++ ) { for ( let k = j ; k * k <= a ; k ++ ) { for ( let l = k ; l * l <= a ; l ++ ) { if ( i * i + j * j + k * k + l * l == a ) { document . write ( a + " " + i + " " + i + " " + j + " " + j + " " ) ; document . write ( k + " " + k + " " + l + " " + l + " " ) ; } } } } } } let a = 74 ; printFourSquares ( a ) ;

Accumulator variables: i, j, k, l
Iterator variables: i, j, k, l
Javascript program:
function exactPrimeFactorCount ( n ) { let count = 0 ; if ( n % 2 == 0 ) { count ++ ; while ( n % 2 == 0 ) n = n / 2 ; } for ( let i = 3 ; i <= Math . sqrt ( n ) ; i = i + 2 ) { if ( n % i == 0 ) { count ++ ; while ( n % i == 0 ) n = n / i ; } } if ( n > 2 ) count ++ ; return count ; } let n = 51242183 ; document . write ( " " + exactPrimeFactorCount ( n ) + " " ) ; document . write ( " " + Math . log ( Math . log ( n ) ) + " " ) ;

Accumulator variables: count
Iterator variables: i
Javascript program:
function checkSemiprime ( num ) { let cnt = 0 ; for ( let i = 2 ; cnt < 2 && i * i <= num ; ++ i ) { while ( num % i == 0 ) { num = parseInt ( num / i , 10 ) ; ++ cnt ; } } if ( num > 1 ) ++ cnt ; return cnt == 2 ; } function isEmirpimes ( n ) { if ( checkSemiprime ( n ) == false ) return false ; let r = 0 ; for ( let t = n ; t != 0 ; t = parseInt ( t / n , 10 ) ) r = r * 10 + t % 10 ; if ( r == n ) return false ; return ( checkSemiprime ( r ) ) ; } let n = 15 ; if ( isEmirpimes ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Iterator variables: i, t
Javascript program:
function gen ( n , r ) { var a = r [ r . length - 1 ] ; a ++ ; for ( var i = 1 ; i <= n ; a += 2 , i ++ ) r . push ( a ) ; return r ; } function conell ( n ) { var res = [ ] ; var k = 1 ; res . push ( 0 ) ; while ( 1 ) { res = gen ( k , res ) ; k ++ ; var j = res . length - 1 ; while ( j != n && j + k > n ) k -- ; if ( j >= n ) break ; } res . shift ( ) ; return res ; } var n = 10 ; document . write ( " " + n + " " + " " ) ; var res = conell ( n ) ; for ( var i = 0 ; i < res . length ; i ++ ) document . write ( res [ i ] + " " ) ;

Index/key variables: i
Accumulator variables: a, i, k
Iterator variables: i
Javascript program:
function factorial ( n ) { let res = 1 ; for ( let i = 2 ; i <= n ; i ++ ) { res *= i ; } return res ; } function printNComposite ( n ) { let fact = factorial ( n + 1 ) ; for ( let i = 2 ; i <= n + 1 ; ++ i ) { document . write ( fact + i + " " ) ; } } let n = 4 ; printNComposite ( n ) ;

Accumulator variables: i, res
Iterator variables: i
Javascript program:
function primes ( n ) { var prime = Array ( n + 1 ) . fill ( true ) ; for ( var i = 2 ; i * i <= n ; i ++ ) { if ( prime [ i ] == true ) { for ( var j = i * 2 ; j <= n ; j += i ) prime [ j ] = false ; } } var arr = [ ] ; for ( var i = 2 ; i < n ; i ++ ) if ( prime [ i ] ) arr . push ( i ) ; return arr ; } function countDigits ( n ) { var temp = n ; var c = 0 ; while ( temp != 0 ) { temp = parseInt ( temp / 10 ) ; c ++ ; } return c ; } function frugal ( n ) { var r = primes ( n ) ; var t = n ; var s = 0 ; for ( var i = 0 ; i < r . length ; i ++ ) { if ( t % r [ i ] == 0 ) { var k = 0 ; while ( t % r [ i ] == 0 ) { t = parseInt ( t / r [ i ] ) ; k ++ ; } if ( k == 1 ) s = s + countDigits ( r [ i ] ) ; else if ( k != 1 ) s = s + countDigits ( r [ i ] ) + countDigits ( k ) ; } } return ( countDigits ( n ) > s && s != 0 ) ; } var n = 343 ; if ( frugal ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: c, i, j, k
Iterator variables: i, j
Javascript program:
function findS ( s ) { let sum = 0 ; for ( let n = 1 ; sum < s ; n ++ ) { sum += n * n * n ; if ( sum == s ) return n ; } return - 1 ; } let s = 9 ; let n = findS ( s ) ; n == - 1 ? document . write ( " " ) : document . write ( n ) ;

Accumulator variables: n, sum
Iterator variables: n
Javascript program:
function NicomachuTheorum_sum ( n ) { let sum = 0 ; for ( let k = 1 ; k <= n ; k ++ ) sum += k * k * k ; let triNo = n * ( n + 1 ) / 2 ; if ( sum == triNo * triNo ) document . write ( " " ) ; else document . write ( " " ) ; } let n = 5 ; NicomachuTheorum_sum ( n ) ;

Accumulator variables: k, sum
Iterator variables: k
Javascript program:
function checkDigits ( n ) { while ( n > 0 ) { if ( ( ( n % 10 ) % 2 ) > 0 ) return 0 ; n = parseInt ( n / 10 ) ; } return 1 ; } function largestNumber ( n ) { for ( i = n ; ; i -- ) if ( checkDigits ( i ) > 0 ) return i ; } var N = 23 ; document . write ( largestNumber ( N ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function largestNumber ( n ) { var s = " " ; var duplicate = n ; while ( n > 0 ) { s = String . fromCharCode ( n % 10 + 48 ) + s ; n = parseInt ( n / 10 ) ; } var index = - 1 ; for ( i = 0 ; i < s . length ; i ++ ) { if ( ( ( ( s . charAt ( i ) . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) % 2 ) & 1 ) > 0 ) { index = i ; break ; } } if ( index == - 1 ) return duplicate ; var num = 0 ; for ( i = 0 ; i < index ; i ++ ) num = num * 10 + ( s . charAt ( i ) . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; num = num * 10 + ( s . charAt ( index ) . charCodeAt ( 0 ) - ( ' ' ) . charCodeAt ( 0 ) - 1 ) ; for ( i = index + 1 ; i < s . length ; i ++ ) num = num * 10 + 8 ; return num ; } var N = 24578 ; document . write ( largestNumber ( N ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function check_digits ( n ) { while ( n != 0 ) { if ( ( n % 10 ) % 2 != 0 ) return 0 ; n = parseInt ( n / 10 ) ; } return 1 ; } function smallest_number ( n ) { for ( i = n ; ; i ++ ) if ( check_digits ( i ) != 0 ) return i ; } var N = 2397 ; document . write ( smallest_number ( N ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX = 50002 ; let primes = [ ] ; function sieve ( ) { let isPrime = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) isPrime [ i ] = true ; for ( let p = 2 ; p * p < MAX ; p ++ ) { if ( isPrime [ p ] == true ) { for ( let i = p * 2 ; i < MAX ; i += p ) isPrime [ i ] = false ; } } for ( let p = 2 ; p < MAX ; p ++ ) if ( isPrime [ p ] == true ) primes . push ( p ) ; } function power ( x , y ) { let count = 0 ; let z = y ; while ( x >= z ) { count += Math . floor ( x / z ) ; z *= y ; } return count ; } function modMult ( a , b , mod ) { let res = 0 ; a = a % mod ; while ( b > 0 ) { if ( b % 2 == 1 ) res = ( res + a ) % mod ; a = ( a * 2 ) % mod ; b = Math . floor ( b / 2 ) ; } return res % mod ; } function countWays ( n , m ) { let ans = 1 ; for ( let i = 1 ; i < primes . length ; i ++ ) { let powers = power ( n , primes [ i ] ) ; if ( powers == 0 ) break ; ans = modMult ( ans , powers + 1 , m ) % m ; } if ( ( ( ans - 1 ) % m ) < 0 ) return ( ans - 1 + m ) % m ; else return ( ans - 1 ) % m ; } sieve ( ) ; let n = 4 , m = 7 ; document . write ( countWays ( n , m ) ) ;

Index/key variables: i, p
Accumulator variables: count, i, p, z
Iterator variables: i, p
Javascript program:
function sumofFactors ( n ) { let res = 1 ; for ( let i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { let count = 0 , curr_sum = 1 ; let curr_term = 1 ; while ( n % i == 0 ) { count ++ ; n = n / i ; curr_term *= i ; curr_sum += curr_term ; } res *= curr_sum ; } if ( n >= 2 ) res *= ( 1 + n ) ; return res ; } function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function checkFriendly ( n , m ) { let sumFactors_n = sumofFactors ( n ) ; let sumFactors_m = sumofFactors ( m ) ; let gcd_n = gcd ( n , sumFactors_n ) ; let gcd_m = gcd ( m , sumFactors_m ) ; if ( n / gcd_n == m / gcd_m && sumFactors_n / gcd_n == sumFactors_m / gcd_m ) return true ; else return false ; } let n = 6 , m = 28 ; if ( checkFriendly ( n , m ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: count, curr_sum, curr_term, i, res
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 primorial ( n ) { let p = 2 ; n -- ; for ( let i = 3 ; n != 0 ; i ++ ) { if ( isPrime ( i ) == true ) { p = p * i ; n -- ; } i ++ ; } return p ; } function findNextPrime ( n ) { let nextPrime = n + 2 ; while ( true ) { if ( isPrime ( nextPrime ) == true ) break ; nextPrime ++ ; } return nextPrime ; } function fortunateNumber ( n ) { let p = primorial ( n ) ; return findNextPrime ( p ) - p ; } let n = 5 ; document . write ( fortunateNumber ( n ) ) ;

Accumulator variables: i, n, nextPrime
Iterator variables: i
Javascript program:
function testSomeNumbers ( limit , n ) { if ( n < 3 ) return ; for ( let a = 1 ; a <= limit ; a ++ ) for ( let b = a ; b <= limit ; b ++ ) { let pow_sum = ( Math . pow ( a , n ) + Math . pow ( b , n ) ) ; let c = Math . pow ( pow_sum , 1.0 / n ) ; let c_pow = Math . pow ( Math . round ( c ) , n ) ; if ( c_pow == pow_sum ) { document . write ( " " ) ; return ; } } document . write ( " " + " " ) ; } testSomeNumbers ( 12 , 5 ) ;

Accumulator variables: a, b
Iterator variables: a, b
Javascript program:
function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function productReduce ( n , num , den ) { let new_num = 1 , new_den = 1 ; for ( let i = 0 ; i < n ; i ++ ) { new_num *= num [ i ] ; new_den *= den [ i ] ; } let GCD = gcd ( new_num , new_den ) ; new_num /= GCD ; new_den /= GCD ; document . write ( new_num + " " + new_den ) ; } let n = 3 ; let num = [ 1 , 2 , 5 ] ; let den = [ 2 , 1 , 6 ] ; productReduce ( n , num , den ) ;

Index/key variables: i
Accumulator variables: i, new_den, new_num
Iterator variables: i
Javascript program:
function totalSumDivisibleByNum ( n , number ) { let firstnum = Math . pow ( 10 , n - 1 ) ; let lastnum = Math . pow ( 10 , n ) ; let sum = 0 ; for ( let i = firstnum ; i < lastnum ; i ++ ) if ( i % number == 0 ) sum += i ; return sum ; } let n = 3 , num = 7 ; document . write ( totalSumDivisibleByNum ( n , num ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function numberofterm ( n , number ) { let firstnum = Math . pow ( 10 , n - 1 ) ; let lastnum = Math . pow ( 10 , n ) ; let count = 0 ; for ( let i = firstnum ; i < lastnum ; i ++ ) if ( i % number == 0 ) count ++ ; return count ; } let n = 3 , num = 7 ; document . write ( numberofterm ( n , num ) ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function georgeCantor ( n ) { let i = 1 ; let j = 1 ; let k = 1 ; while ( k < n ) { j ++ ; k ++ ; if ( k == n ) break ; while ( j > 1 && k < n ) { i ++ ; j -- ; k ++ ; } if ( k == n ) break ; i ++ ; k ++ ; if ( k == n ) break ; while ( i > 1 && k < n ) { i -- ; j ++ ; k ++ ; } } document . write ( " " + i + " " + j ) ; } let n = 15 ; georgeCantor ( n ) ;

Accumulator variables: i, j, k
Javascript program:
function isDivisible ( n ) { while ( parseInt ( n / 100 ) ) { let last_digit = n % 10 ; n = parseInt ( n / 10 ) ; n += last_digit * 3 ; } return ( n % 29 == 0 ) ; } let n = 348 ; if ( isDivisible ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: n
Javascript program:
let MAX = 100000 function multiply ( x , res , res_size ) { let carry = 0 ; for ( let i = 0 ; i < res_size ; i ++ ) { let prod = res [ i ] * x + carry ; res [ i ] = prod % 10 ; carry = Math . floor ( prod / 10 ) ; } while ( carry ) { res [ res_size ] = carry % 10 ; carry = Math . floor ( carry / 10 ) ; res_size ++ ; } return res_size ; } function power ( x , n ) { if ( n == 0 ) { document . write ( " " ) ; return ; } let res = new Array ( MAX ) ; let res_size = 0 ; let temp = x ; while ( temp != 0 ) { res [ res_size ++ ] = temp % 10 ; temp = Math . floor ( temp / 10 ) ; } for ( let i = 2 ; i <= n ; i ++ ) res_size = multiply ( x , res , res_size ) ; document . write ( x + " " + n + " " ) ; for ( let i = res_size - 1 ; i >= 0 ; i -- ) document . write ( res [ i ] ) ; } let exponent = 100 ; let base = 2 ; power ( base , exponent ) ;

Index/key variables: i, res_size
Accumulator variables: i, res_size
Iterator variables: i
Javascript program:
function check ( n , p ) { let maximum = - 1 ; while ( ! ( n % 2 ) ) { maximum = Math . max ( maximum , 2 ) n = n / 2 ; } var i ; for ( i = 3 ; i * i <= n ; i += 2 ) { while ( n % i == 0 ) { maximum = Math . max ( maximum , i ) ; n = n / i ; } } if ( n > 2 ) maximum = Math . max ( maximum , n ) ; if ( maximum <= p ) return true ; else return false ; } let n = 24 , p = 7 ; if ( check ( n , p ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function isPrime ( n ) { if ( n == 0 n == 1 ) return false ; let root = Math . sqrt ( n ) ; for ( let i = 2 ; i <= root ; i ++ ) if ( n % i == 0 ) return false ; return true ; } function isSandwitched ( n ) { return ( isPrime ( n - 1 ) && isPrime ( n + 1 ) ) ; } let n = 642 ; document . write ( n + " " ) ; if ( isSandwitched ( n ) ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ; n = 9 ; document . write ( n + " " ) ; if ( isSandwitched ( n ) ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function day_of_the_week ( y , m , d ) { let t = [ 0 , 3 , 2 , 5 , 0 , 3 , 5 , 1 , 4 , 6 , 2 , 4 ] ; if ( m < 3 ) y -= 1 ; return ( y + y / 4 - y / 100 + y / 400 + t [ m - 1 ] + d ) % 7 ; } let day = 13 , month = 7 , year = 2017 ; document . write ( Math . round ( day_of_the_week ( year , month , day ) ) ) ;

Accumulator variables: y
Javascript program:
function isSquareFree ( n ) { if ( n % 2 == 0 ) n = n / 2 ; if ( n % 2 == 0 ) return false ; for ( let i = 3 ; i <= Math . sqrt ( n ) ; i = i + 2 ) { if ( n % i == 0 ) { n = n / i ; if ( n % i == 0 ) return false ; } } return true ; } let n = 10 ; if ( isSquareFree ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Iterator variables: i
Javascript program:
function sumOfSeries ( n ) { let sum = 0 ; for ( let i = 1 ; i <= n ; i ++ ) sum = sum + ( 2 * i - 1 ) * ( 2 * i - 1 ) ; return sum ; } let n = 10 ; document . write ( sumOfSeries ( n ) ) ;

Accumulator variables: i
Iterator variables: i