dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def sum ( n ) :
    rem = 0
    sum_of_digits = 0
    while ( n > 0 ) :
        rem = n % 10
        sum_of_digits += rem
        n = n // 10
    return sum_of_digits
def count ( n ) :
    c = 0
    for i in range ( n - 97 , n + 1 ) :
        a = sum ( i )
        b = sum ( a )
        if ( ( i + a + b ) == n ) :
            c += 1
    return c
n = 9939
print ( count ( n ) )

Accumulator variables: c, sum_of_digits
Iterator variables: i
Python program:
def isPowerOfK ( n , k ) :
    oneSeen = False
    while ( n > 0 ) :
        digit = n % k
        if ( digit > 1 ) :
            return False
        if ( digit == 1 ) :
            if ( oneSeen ) :
                return False
            oneSeen = True
        n //= k
    return True
n = 64
k = 4
if ( isPowerOfK ( n , k ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Accumulator variables: n
Boolean variables: oneSeen
Python program:
MAX_DIGITS = 20 ;
def isOctal ( n ) :
    while ( n ) :
        if ( ( n % 10 ) >= 8 ) :
            return False
        else :
            n = int ( n / 10 )
    return True
def isPalindrome ( n ) :
    divide = 8 if ( isOctal ( n ) == False ) else 10
    octal = [ ]
    while ( n != 0 ) :
        octal . append ( n % divide )
        n = int ( n / divide )
    j = len ( octal ) - 1
    k = 0
    while ( k <= j ) :
        if ( octal [ j ] != octal [ k ] ) :
            return False
        j -= 1
        k += 1
    return True
if __name__ == ' _ _ main _ _ ' :
    n = 97 ;
    if ( isPalindrome ( n ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: j, k
Accumulator variables: octal
Python program:
def printFactorialNums ( n ) :
    fact = 1
    x = 2
    while fact <= n :
        print ( fact , end = " ▁ " )
        fact = fact * x
        x += 1
n = 100
printFactorialNums ( n )

Accumulator variables: x
Python program:
def sumDigitSquare ( n ) :
    sq = 0 ;
    while ( n != 0 ) :
        digit = n % 10
        sq += digit * digit
        n = n // 10
    return sq ;
def isHappy ( n ) :
    s = set ( )
    s . add ( n )
    while ( True ) :
        if ( n == 1 ) :
            return True ;
        n = sumDigitSquare ( n )
        if n in s :
            return False
        s . add ( n )
    return false ;
n = 4
if ( isHappy ( n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Accumulator variables: s, sq
Python program:
from math import sqrt
def isPrime ( n ) :
    if ( n <= 1 ) :
        return False
    if ( n <= 3 ) :
        return True
    if ( n % 2 == 0 or n % 3 == 0 ) :
        return False
    k = int ( sqrt ( n ) ) + 1
    for i in range ( 5 , k , 6 ) :
        if ( n % i == 0 or n % ( i + 2 ) == 0 ) :
            return False
    return True
def isThreeDisctFactors ( n ) :
    sq = int ( sqrt ( n ) )
    if ( 1 * sq * sq != n ) :
        return False
    if ( isPrime ( sq ) ) :
        return True
    else :
        return False
if __name__ == ' _ _ main _ _ ' :
    num = 9
    if ( isThreeDisctFactors ( num ) ) :
        print ( " Yes " )
    else :
        print ( " No " )
    num = 15
    if ( isThreeDisctFactors ( num ) ) :
        print ( " Yes " )
    else :
        print ( " No " )
    num = 12397923568441
    if ( isThreeDisctFactors ( num ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Iterator variables: i
Python program:
def printTrib ( n ) :
    if ( n < 1 ) :
        return
    first = 0
    second = 0
    third = 1
    print ( first , " ▁ " , end = " " )
    if ( n > 1 ) :
        print ( second , " ▁ " , end = " " )
    if ( n > 2 ) :
        print ( second , " ▁ " , end = " " )
    for i in range ( 3 , n ) :
        curr = first + second + third
        first = second
        second = third
        third = curr
        print ( curr , " ▁ " , end = " " )
n = 10
printTrib ( n )

Iterator variables: i
Python program:
def getMax ( arr , ans , chosen , N ) :
    if len ( arr ) == N :
        ans = max ( ans , calcScr ( arr ) )
        return ans
    for i in range ( N ) :
        if chosen [ i ] :
            continue
        chosen [ i ] = True
        arr . append ( i )
        ans = getMax ( arr , ans , chosen , N )
        chosen [ i ] = False
        arr . pop ( )
    return ans
def calcScr ( arr ) :
    ans = 0
    for i in range ( len ( arr ) ) :
        ans += ( i ^ arr [ i ] )
    return ans
N = 2
arr = [ ]
ans = - 1
chosen = [ False for i in range ( N ) ]
ans = getMax ( arr , ans , chosen , N )
print ( ans )

Index/key variables: i
Accumulator variables: ans, arr
Iterator variables: i
Python program:
def additiveCongruentialMethod ( Xo , m , c , randomNums , noOfRandomNums ) :
    randomNums [ 0 ] = Xo
    for i in range ( 1 , noOfRandomNums ) :
        randomNums [ i ] = ( randomNums [ i - 1 ] + c ) % m
if __name__ == ' _ _ main _ _ ' :
    Xo = 3
    m = 15
    c = 2
    noOfRandomNums = 20
    randomNums = [ 0 ] * ( noOfRandomNums )
    additiveCongruentialMethod ( Xo , m , c , randomNums , noOfRandomNums )
    for i in randomNums :
        print ( i , end = " ▁ " )

Index/key variables: i
Iterator variables: i
Python program:
from queue import PriorityQueue
def lastElement ( arr ) :
    pq = PriorityQueue ( )
    for i in range ( len ( arr ) ) :
        pq . put ( - 1 * arr [ i ] )
    m1 = 0
    m2 = 0
    while not pq . empty ( ) :
        if pq . qsize ( ) == 1 :
            return - 1 * pq . get ( )
        else :
            m1 = - 1 * pq . get ( )
            m2 = - 1 * pq . get ( )
        if m1 != m2 :
            pq . put ( - 1 * abs ( m1 - m2 ) )
    return 0
arr = [ 2 , 7 , 4 , 1 , 8 , 1 , 1 ]
print ( lastElement ( arr ) )

Index/key variables: i
Iterator variables: i
Python program:
def formed_no ( N , K ) :
    if ( K == 1 ) :
        return N
    answer = N
    while ( K != 0 ) :
        a_current = prod_of_max_min ( answer )
        if ( a_current == 0 ) :
            break
        answer += a_current
        K -= 1
    return answer
def prod_of_max_min ( n ) :
    largest = 0
    smallest = 10
    while ( n != 0 ) :
        r = n % 10
        largest = max ( r , largest )
        smallest = min ( r , smallest )
        n = n // 10
    return largest * smallest
if __name__ == " _ _ main _ _ " :
    N = 487
    K = 100000000
    print ( formed_no ( N , K ) )

Accumulator variables: K, answer
Python program:
def sum ( x , n ) :
    total = 1.0
    multi = x
    print ( 1 , end = " ▁ " )
    for i in range ( 1 , n ) :
        total = total + multi
        print ( ' % .1f ' % multi , end = " ▁ " )
        multi = multi * x
    print ( ' ' )
    return total ;
x = 2
n = 5
print ( ' % .2f ' % sum ( x , n ) )

Iterator variables: i
Python program:
from math import pow
def isAutoBio ( num ) :
    autoStr = str ( num )
    for i in range ( 0 , len ( autoStr ) ) :
        index = int ( autoStr [ i ] )
        cnt = 0
        for j in range ( 0 , len ( autoStr ) ) :
            number = int ( autoStr [ j ] )
            if number == i :
                cnt += 1
        if cnt != index :
            return False
    return True
def findAutoBios ( n ) :
    low = int ( pow ( 10 , n - 1 ) )
    high = int ( pow ( 10 , n ) - 1 )
    flag = 0
    for i in range ( low , high + 1 ) :
        if isAutoBio ( i ) :
            flag = 1
            print ( i , end = ' , ▁ ' )
    if flag == 0 :
        print ( " There ▁ is ▁ no ▁ Autobiographical ▁ Number ▁ with ▁ " + str ( n ) + " ▁ digits " )
if __name__ == " _ _ main _ _ " :
    N = 0
    findAutoBios ( N )
    N = 4
    findAutoBios ( N )

Index/key variables: i, j
Accumulator variables: cnt
Iterator variables: i, j
Python program:
def checkPalindrome ( num ) :
    string = str ( num )
    l = 0
    r = len ( string ) - 1 ;
    while ( l < r ) :
        if ( string [ l ] != string [ r ] ) :
            print ( " No " )
            return ;
        l = l + 1 ;
        r = r - 1 ;
    print ( " Yes " )
    return ;
if __name__ == ' _ _ main _ _ ' :
    n = 19
    k = 3
    checkPalindrome ( n + k ) ;

Index/key variables: l, r
Python program:
def subsetSum ( arr , n , i , sum , count ) :
    if ( i == n ) :
        if ( sum == 0 ) :
            count += 1
        return count
    count = subsetSum ( arr , n , i + 1 , sum - arr [ i ] , count )
    count = subsetSum ( arr , n , i + 1 , sum , count )
    return count
arr = [ 1 , 2 , 3 , 4 , 5 ]
sum = 10
n = len ( arr )
print ( subsetSum ( arr , n , 0 , sum , 0 ) )

Index/key variables: i
Python program:
def sieve ( n ) :
    prime = [ True ] * ( n + 1 )
    p = 2
    while ( p * p <= n ) :
        if ( prime [ p ] == True ) :
            for i in range ( p * p , n + 1 , p ) :
                prime [ i ] = False
        p += 1
    allPrimes = [ x for x in range ( 2 , n ) if prime [ x ] ]
    return allPrimes
def distPrime ( arr , allPrimes ) :
    list1 = list ( )
    for i in allPrimes :
        for j in arr :
            if ( j % i == 0 ) :
                list1 . append ( i )
                break
    return list1
if __name__ == " _ _ main _ _ " :
    allPrimes = sieve ( 10000 )
    arr = [ 15 , 30 , 60 ]
    ans = distPrime ( arr , allPrimes )
    print ( ans )

Index/key variables: i, p, x
Accumulator variables: list1
Iterator variables: i, j
Python program:
def count_square ( n ) :
    count = 0 ;
    for i in range ( 1 , n + 1 , 2 ) :
        k = n - i + 1 ;
        count += ( k * k ) ;
    return count ;
N = 8 ;
print ( count_square ( N ) ) ;

Accumulator variables: count
Iterator variables: i
Python program:
def countAnomalies ( arr , n , k ) :
    cnt = 0
    i , Sum = 0 , 0
    for i in range ( n ) :
        Sum += arr [ i ]
    for i in range ( n ) :
        if ( abs ( arr [ i ] - ( Sum - arr [ i ] ) ) > k ) :
            cnt += 1
    return cnt
arr = [ 1 , 3 , 5 ]
n = len ( arr )
k = 1
print ( countAnomalies ( arr , n , k ) )

Index/key variables: i
Accumulator variables: Sum, cnt
Iterator variables: i
Python program:
from math import sqrt ;
N = 100005
d = [ 0 ] * N
pre = [ 0 ] * N
def Positive_Divisors ( ) :
    for i in range ( N ) :
        for j in range ( 1 , int ( sqrt ( i ) ) + 1 ) :
            if ( i % j == 0 ) :
                if ( j * j == i ) :
                    d [ i ] += 1
                else :
                    d [ i ] += 2
    ans = 0
    for i in range ( 2 , N ) :
        if ( d [ i ] == d [ i - 1 ] ) :
            ans += 1
        pre [ i ] = ans
if __name__ == " _ _ main _ _ " :
    Positive_Divisors ( )
    n = 15
    print ( pre [ n ] )

Index/key variables: i, n
Accumulator variables: ans
Iterator variables: i, j
Python program:
def numLen ( K ) :
    if ( K % 2 == 0 or K % 5 == 0 ) :
        return - 1 ;
    number = 0 ;
    len = 1 ;
    for len in range ( 1 , K + 1 ) :
        number = number * 10 + 1 ;
        if ( ( number % K == 0 ) ) :
            return len ;
    return - 1 ;
K = 7 ;
print ( numLen ( K ) ) ;

Iterator variables: len
Python program:
def printPermutation ( n , k ) :
    for i in range ( 1 , n + 1 ) :
        x = 2 * i - 1 ;
        y = 2 * i ;
        if ( i <= k ) :
            print ( y , x , end = " ▁ " ) ;
        else :
            print ( x , y , end = " ▁ " ) ;
if __name__ == " _ _ main _ _ " :
    n = 2 ; k = 1 ;
    printPermutation ( n , k ) ;

Iterator variables: i
Python program:
def maxSum ( N ) :
    ans = 0 ;
    for u in range ( 1 , N + 1 ) :
        for v in range ( 1 , N + 1 ) :
            if ( u == v ) :
                continue ;
            degreeU = 2 ;
            if ( u == 1 or u == N ) :
                degreeU = 1 ;
            degreeV = 2 ;
            if ( v == 1 or v == N ) :
                degreeV = 1 ;
            ans += ( degreeU * degreeV ) ;
    return ans ;
if __name__ == " _ _ main _ _ " :
    N = 6 ;
    print ( maxSum ( N ) ) ;

Accumulator variables: ans
Iterator variables: u, v
Python program:
def maximumFactor ( arr ) :
    rank , factors = [ ] , [ ]
    for i in range ( 2 , max ( arr ) + 1 ) :
        count = 0
        for j in arr :
            if j % i == 0 : count += 1
        rank . append ( count )
        factors . append ( i )
    m = max ( rank )
    for i in range ( len ( rank ) ) :
        if rank [ i ] == m :
            print ( factors [ i ] , end = " ▁ " )
arr = [ 120 , 15 , 24 , 63 , 18 ]
maximumFactor ( arr )

Index/key variables: i
Accumulator variables: count, factors, rank
Iterator variables: i, j
Python program:
def findMean ( a , n ) :
    sum = 0
    for i in range ( 0 , n ) :
        sum += a [ i ]
    return float ( sum / n )
a = [ 1 , 3 , 4 , 2 , 7 , 5 , 8 , 6 ]
n = len ( a )
print ( " Mean ▁ = " , findMean ( a , n ) )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
import math
def CheckArray ( arr , n ) :
    prod = 1
    freq = [ ]
    for i in range ( n ) :
        freq . append ( arr [ i ] )
        prod *= arr [ i ]
    root = math . sqrt ( prod )
    if ( root * root == prod ) :
        if root in freq :
            return True
    return False
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 12 , 3 , 2 ]
    n = len ( arr )
    if ( CheckArray ( arr , n ) ) :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i
Accumulator variables: freq, prod
Iterator variables: i
Python program:
import collections
def minAreaRect ( A ) :
    columns = collections . defaultdict ( list )
    for x , y in A :
        columns [ x ] . append ( y )
    lastx = { }
    ans = float ( ' inf ' )
    for x in sorted ( columns ) :
        column = columns [ x ]
        column . sort ( )
        for j , y2 in enumerate ( column ) :
            for i in range ( j ) :
                y1 = column [ i ]
                if ( y1 , y2 ) in lastx :
                    ans = min ( ans , ( x - lastx [ y1 , y2 ] ) * ( y2 - y1 ) )
                lastx [ y1 , y2 ] = x
    if ans < float ( ' inf ' ) :
        return ans
    else :
        return 0
A = [ [ 1 , 1 ] , [ 1 , 3 ] , [ 3 , 1 ] , [ 3 , 3 ] , [ 2 , 2 ] ]
print ( minAreaRect ( A ) )

Index/key variables: i, x
Iterator variables: i, j, x, y, y2
Python program:
MAX = 100000 ;
prime = [ True ] * ( MAX + 1 ) ;
def SieveOfEratosthenes ( ) :
    prime [ 1 ] = False ;
    prime [ 0 ] = False ;
    p = 2 ;
    while ( p * p <= MAX ) :
        if ( prime [ p ] ) :
            i = p * 2 ;
            while ( i <= MAX ) :
                prime [ i ] = False ;
                i += p ;
        p += 1 ;
def SumOfKthPrimes ( arr , n , k ) :
    c = 0 ;
    sum = 0 ;
    for i in range ( n ) :
        if ( prime [ arr [ i ] ] ) :
            c += 1 ;
            if ( c % k == 0 ) :
                sum += arr [ i ] ;
                c = 0 ;
    print ( sum ) ;
SieveOfEratosthenes ( ) ;
arr = [ 2 , 3 , 5 , 7 , 11 ] ;
n = len ( arr ) ;
k = 2 ;
SumOfKthPrimes ( arr , n , k ) ;

Index/key variables: i, p
Accumulator variables: c, sum
Iterator variables: i
Python program:
MAX = 100000 ;
prime = [ True ] * 100002 ;
def SieveOfEratosthenes ( ) :
    p = 2 ;
    while ( p * p <= MAX ) :
        if ( prime [ p ] == True ) :
            i = p * 2 ;
            while ( i <= MAX ) :
                prime [ i ] = False ;
                i += p ;
        p += 1 ;
def superpower ( n ) :
    SieveOfEratosthenes ( ) ;
    superPower = 0 ;
    factor = 0 ;
    i = 2 ;
    while ( n > 1 and i <= MAX ) :
        if ( prime [ i ] ) :
            factor = 0 ;
            while ( n % i == 0 and n > 1 ) :
                factor += 1 ;
                n = int ( n / i ) ;
            if ( superPower < factor ) :
                superPower = factor ;
        i += 1 ;
    return superPower ;
n = 256 ;
print ( superpower ( n ) ) ;

Index/key variables: i, p
Accumulator variables: factor
Python program:
def isPrime ( n ) :
    if n <= 1 :
        return False
    if n <= 3 :
        return True
    if n % 2 == 0 or n % 3 == 0 :
        return False
    i = 5
    while i * i <= n :
        if n % i == 0 or n % ( i + 2 ) == 0 :
            return False
        i += 6
    return True
class Node :
    def __init__ ( self , data , next ) :
        self . data = data
        self . next = next
class LinkedList :
    def __init__ ( self ) :
        self . head = None
    def push ( self , new_data ) :
        new_node = Node ( new_data , self . head )
        self . head = new_node
    def countPrime ( self ) :
        count = 0
        ptr = self . head
        while ptr != None :
            if isPrime ( ptr . data ) :
                count += 1
            ptr = ptr . next
        return count
if __name__ == " _ _ main _ _ " :
    linkedlist = LinkedList ( )
    linkedlist . push ( 17 )
    linkedlist . push ( 10 )
    linkedlist . push ( 6 )
    linkedlist . push ( 5 )
    linkedlist . push ( 15 )
    print ( " Count ▁ of ▁ prime ▁ nodes ▁ = " , linkedlist . countPrime ( ) )

Accumulator variables: count, i
Class/struct names: LinkedList, Node
Python program:
def smallestDivisor ( n ) :
    if ( n % 2 == 0 ) :
        return 2 ;
    i = 3 ;
    while ( i * i <= n ) :
        if ( n % i == 0 ) :
            return i ;
        i += 2 ;
    return n ;
n = 31 ;
print ( smallestDivisor ( n ) ) ;

Accumulator variables: i
Python program:
def xorEqualsOrCount ( N ) :
    count = 0
    while ( N > 0 ) :
        bit = N % 2
        if bit == 0 :
            count += 1
        N //= 2
    return int ( pow ( 2 , count ) )
if __name__ == " _ _ main _ _ " :
    N = 7
    print ( xorEqualsOrCount ( N ) )

Accumulator variables: N, count
Python program:
def fact ( n ) :
    if n == 1 :
        return 1
    else :
        return n * fact ( n - 1 )
def sum ( x , n ) :
    total = 1.0
    for i in range ( 1 , n + 1 , 1 ) :
        total = total + ( pow ( x , i ) / fact ( i + 1 ) )
    return total
if __name__ == ' _ _ main _ _ ' :
    x = 5
    n = 4
    print ( " Sum ▁ is : ▁ { 0 : . 4f } " . format ( sum ( x , n ) ) )

Iterator variables: i
Python program:
def sum_of_series ( n ) :
    result = 0
    for i in range ( 1 , n + 1 ) :
        if ( i % 2 == 0 ) :
            result = result - pow ( i , 2 )
        else :
            result = result + pow ( i , 2 )
    return result
if __name__ == " _ _ main _ _ " :
    n = 3
    print ( sum_of_series ( n ) )
    n = 10
    print ( sum_of_series ( n ) )

Iterator variables: i
Python program:
from math import *
def isPower ( a ) :
    if a == 1 :
        return True
    for i in range ( 2 , int ( sqrt ( a ) ) + 1 ) :
        val = log ( a ) / log ( i )
        if ( round ( ( val - int ( val ) ) , 8 ) < 0.00000001 ) :
            return True
    return False
if __name__ == " _ _ main _ _ " :
    n = 16
    if isPower ( n ) :
        print ( " Yes " )
    else :
        print ( " No " )

Iterator variables: i
Python program:
import math
def rmsValue ( arr , n ) :
    square = 0
    mean = 0.0
    root = 0.0
    for i in range ( 0 , n ) :
        square += ( arr [ i ] ** 2 )
    mean = ( square / ( float ) ( n ) )
    root = math . sqrt ( mean )
    return root
if __name__ == ' _ _ main _ _ ' :
    arr = [ 10 , 4 , 6 , 8 ]
    n = len ( arr )
    print ( rmsValue ( arr , n ) )

Index/key variables: i
Accumulator variables: square
Iterator variables: i
Python program:
import sys
def findLCM ( a , b ) :
    lar = max ( a , b )
    small = min ( a , b )
    i = lar
    while ( 1 ) :
        if ( i % small == 0 ) :
            return i
        i += lar
a = 5
b = 7
print ( " LCM ▁ of ▁ " , a , " ▁ and ▁ " , b , " ▁ is ▁ " , findLCM ( a , b ) , sep = " " )

Accumulator variables: i
Python program:
from __future__ import print_function
def primes ( n ) :
    i , j = 2 , 0
    result = [ ]
    while j < n :
        flag = True
        for item in range ( 2 , int ( i ** 0.5 ) + 1 ) :
            if i % item == 0 and i != item :
                flag = False
                break
        if flag :
            result . append ( i )
            j += 1
        i += 1
    return result
def smar_wln ( n ) :
    arr = primes ( n )
    for i in range ( 0 , len ( arr ) ) :
        for j in range ( 0 , i + 1 ) :
            print ( arr [ j ] , end = ' ' )
        print ( end = ' ▁ ' )
if __name__ == ' _ _ main _ _ ' :
    n = 5
    print ( ' First { } terms of the Sequence are ' . format ( n ) )
    smar_wln ( n )

Index/key variables: j
Accumulator variables: result
Iterator variables: i, item, j
Boolean variables: flag
Python program:
import math
def SieveOfEratosthenes ( n , prime , primesquare , a ) :
    for i in range ( 2 , n + 1 ) :
        prime [ i ] = True ;
    for i in range ( ( n * n + 1 ) + 1 ) :
        primesquare [ i ] = False ;
    prime [ 1 ] = False ;
    p = 2 ;
    while ( p * p <= n ) :
        if ( prime [ p ] == True ) :
            for i in range ( p * 2 , n + 1 , p ) :
                prime [ i ] = False ;
        p += 1 ;
    j = 0 ;
    for p in range ( 2 , n + 1 ) :
        if ( prime [ p ] ) :
            a [ j ] = p ;
            primesquare [ p * p ] = True ;
            j += 1 ;
def countDivisors ( n ) :
    if ( n == 1 ) :
        return 1 ;
    prime = [ False ] * ( n + 2 ) ;
    primesquare = [ False ] * ( n * n + 3 ) ;
    a = [ 0 ] * n ;
    SieveOfEratosthenes ( n , prime , primesquare , a ) ;
    ans = 1 ;
    for i in range ( 0 , True ) :
        if ( a [ i ] * a [ i ] * a [ i ] > n ) :
            break ;
        cnt = 1 ;
        while ( n % a [ i ] == 0 ) :
            n //= a [ i ] ;
            cnt = cnt + 1 ;
        ans = ans * cnt ;
    if ( prime [ n ] ) :
        ans = ans * 2 ;
    elif ( primesquare [ n ] ) :
        ans = ans * 3 ;
    elif ( n != 1 ) :
        ans = ans * 4 ;
def sumofFactors ( n ) :
    res = 1 ;
    for i in range ( 2 , int ( math . sqrt ( n ) ) + 1 ) :
        count = 0 ;
        curr_sum = 1 ;
        curr_term = 1 ;
        while ( n % i == 0 ) :
            count += 1 ;
            n //= i ;
            curr_term *= i ;
            curr_sum += curr_term ;
        res *= curr_sum ;
    if ( n >= 2 ) :
        res *= ( 1 + n ) ;
    return res ;
def checkArithmetic ( n ) :
    count = countDivisors ( n ) ;
    sum = sumofFactors ( n ) ;
    return ( sum % count == 0 ) ;
n = 6 ;
if ( checkArithmetic ( n ) ) :
    print ( " Yes " ) ;
else :
    print ( " No " ) ;

Index/key variables: i, j, n, p
Accumulator variables: count, curr_sum, curr_term, res
Iterator variables: i, p
Python program:
power = [ ]
def nextPower ( N ) :
    global power
    carry = 0
    for i in range ( 0 , len ( power ) ) :
        prod = ( power [ i ] * N ) + carry
        power [ i ] = prod % 10
        carry = ( int ) ( prod / 10 )
    while ( carry ) :
        power . append ( carry % 10 )
        carry = ( int ) ( carry / 10 )
def printPowerNumber ( X , N ) :
    global power
    power . append ( 1 )
    res = [ ]
    for i in range ( 1 , X + 1 ) :
        nextPower ( N )
        res . append ( power [ - 1 ] )
        res . append ( power [ 0 ] )
    for i in range ( 0 , len ( res ) ) :
        print ( res [ i ] , end = " " )
N = 19
X = 4
printPowerNumber ( X , N )

Index/key variables: i
Accumulator variables: power, res
Iterator variables: i
Python program:
import math
def firstDigit ( n ) :
    fact = 1
    for i in range ( 2 , n + 1 ) :
        fact = fact * i
        while ( fact % 10 == 0 ) :
            fact = int ( fact / 10 )
    while ( fact >= 10 ) :
        fact = int ( fact / 10 )
    return math . floor ( fact )
n = 5
print ( firstDigit ( n ) )

Iterator variables: i
Python program:
def sumofseries ( n ) :
    res = 0
    for i in range ( 1 , n + 1 ) :
        res += ( i ) * ( i + 1 ) * ( i + 2 )
    return res
print ( sumofseries ( 3 ) )

Accumulator variables: res
Iterator variables: i
Python program:
import math
def printGMeans ( A , B , N ) :
    R = ( math . pow ( ( B / A ) , 1.0 / ( N + 1 ) ) ) ;
    for i in range ( 1 , N + 1 ) :
        print ( int ( A * math . pow ( R , i ) ) , end = " ▁ " ) ;
A = 3 ;
B = 81 ;
N = 2 ;
printGMeans ( A , B , N ) ;

Iterator variables: i
Python program:
def digitSum ( n ) :
    digSum = 0
    while ( n > 0 ) :
        digSum += n % 10
        n //= 10
    return digSum
def countInteger ( n , s ) :
    if ( n < s ) :
        return 0
    for i in range ( s , min ( n , s + 163 ) + 1 ) :
        if ( ( i - digitSum ( i ) ) > s ) :
            return ( n - i + 1 )
    return 0
n = 1000
s = 100
print ( countInteger ( n , s ) )

Accumulator variables: digSum, n
Iterator variables: i