dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def primes ( n ) :
    prime = [ True ] * ( n + 1 ) ;
    i = 2 ;
    while ( i * i <= n ) :
        if ( prime [ i ] == True ) :
            j = i * 2 ;
            while ( j <= n ) :
                prime [ j ] = False ;
                j += i ;
        i += 1 ;
    arr = [ ] ;
    for i in range ( 2 , n ) :
        if ( prime [ i ] ) :
            arr . append ( i ) ;
    return arr ;
def countDigits ( n ) :
    temp = n ;
    c = 0 ;
    while ( temp != 0 ) :
        temp = int ( temp / 10 ) ;
        c += 1 ;
    return c ;
def frugal ( n ) :
    r = primes ( n ) ;
    t = n ;
    s = 0 ;
    for i in range ( len ( r ) ) :
        if ( t % r [ i ] == 0 ) :
            k = 0 ;
            while ( t % r [ i ] == 0 ) :
                t = int ( t / r [ i ] ) ;
                k += 1 ;
            if ( k == 1 ) :
                s = s + countDigits ( r [ i ] ) ;
            elif ( k != 1 ) :
                s = ( s + countDigits ( r [ i ] ) + countDigits ( k ) ) ;
    return ( countDigits ( n ) > s and s != 0 ) ;
n = 343 ;
if ( frugal ( n ) ) :
    print ( " A ▁ Frugal ▁ number " ) ;
else :
    print ( " Not ▁ a ▁ frugal ▁ number " ) ;

Index/key variables: i, j
Accumulator variables: arr, c, k
Iterator variables: i
Python program:
def findS ( s ) :
    _sum = 0
    n = 1
    while ( _sum < s ) :
        _sum += n * n * n
        n += 1
    n -= 1
    if _sum == s :
        return n
    return - 1
s = 9
n = findS ( s )
if n == - 1 :
    print ( " - 1" )
else :
    print ( n )

Accumulator variables: _sum, n
Python program:
def NicomachuTheorum_sum ( n ) :
    sum = 0 ;
    for k in range ( 1 , n + 1 ) :
        sum += k * k * k ;
    triNo = n * ( n + 1 ) / 2 ;
    if ( sum == triNo * triNo ) :
        print ( " Yes " ) ;
    else :
        print ( " No " ) ;
n = 5 ;
NicomachuTheorum_sum ( n ) ;

Accumulator variables: sum
Iterator variables: k
Python program:
def checkDigits ( n ) :
    while ( n > 0 ) :
        if ( ( n % 10 ) % 2 ) :
            return False ;
        n = int ( n / 10 ) ;
    return True ;
def largestNumber ( n ) :
    for i in range ( n , - 1 , - 1 ) :
        if ( checkDigits ( i ) ) :
            return i ;
N = 23 ;
print ( largestNumber ( N ) ) ;

Iterator variables: i
Python program:
import math as mt
def largestNumber ( n ) :
    s = " "
    duplicate = n
    while ( n > 0 ) :
        s = chr ( n % 10 + 48 ) + s
        n = n // 10
    index = - 1
    for i in range ( len ( s ) ) :
        if ( ( ord ( s [ i ] ) - ord ( '0' ) ) % 2 & 1 ) :
            index = i
            break
    if ( index == - 1 ) :
        return duplicate
    num = 0
    for i in range ( index ) :
        num = num * 10 + ( ord ( s [ i ] ) - ord ( '0' ) )
    num = num * 10 + ( ord ( s [ index ] ) - ord ( '0' ) - 1 )
    for i in range ( index + 1 , len ( s ) ) :
        num = num * 10 + 8
    return num
N = 24578
print ( largestNumber ( N ) )

Index/key variables: i, index
Iterator variables: i
Python program:
def check_digits ( n ) :
    while ( n ) :
        if ( ( n % 10 ) % 2 ) :
            return 0
        n = int ( n / 10 )
    return 1
def smallest_number ( n ) :
    for i in range ( n , 2401 ) :
        if ( check_digits ( i ) == 1 ) :
            return ( i )
N = 2397
print ( str ( smallest_number ( N ) ) )

Iterator variables: i
Python program:
MAX = 50002 ;
primes = [ ]
def sieve ( ) :
    isPrime = [ True ] * ( MAX )
    p = 2
    while p * p < MAX :
        if ( isPrime [ p ] == True ) :
            for i in range ( p * 2 , MAX , p ) :
                isPrime [ i ] = False
        p += 1
    for p in range ( 2 , MAX ) :
        if ( isPrime [ p ] ) :
            primes . append ( p )
def power ( x , y ) :
    count = 0
    z = y
    while ( x >= z ) :
        count += ( x // z )
        z *= y
    return count
def modMult ( a , b , mod ) :
    res = 0
    a = a % mod
    while ( b > 0 ) :
        if ( b % 2 == 1 ) :
            res = ( res + a ) % mod
        a = ( a * 2 ) % mod
        b //= 2
    return res % mod
def countWays ( n , m ) :
    ans = 1
    for i in range ( 1 , len ( primes ) ) :
        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
if __name__ == " _ _ main _ _ " :
    sieve ( )
    n = 4
    m = 7
    print ( countWays ( n , m ) )

Index/key variables: i, p
Accumulator variables: b, count, primes, z
Iterator variables: i, p
Python program:
import math
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 = n // i
            curr_term *= i
            curr_sum += curr_term
        res *= curr_sum
    if ( n >= 2 ) :
        res *= ( 1 + n )
    return res
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b
    return gcd ( b % a , a )
def checkFriendly ( n , m ) :
    sumFactors_n = sumofFactors ( n )
    sumFactors_m = sumofFactors ( m )
    gcd_n = gcd ( n , sumFactors_n )
    gcd_m = gcd ( m , sumFactors_m )
    if ( n // gcd_n == m // gcd_m and sumFactors_n // gcd_n == sumFactors_m // gcd_m ) :
        return True
    else :
        return False
n = 6 ; m = 28
if ( checkFriendly ( n , m ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Accumulator variables: count, curr_sum, curr_term, res
Iterator variables: i
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
def primorial ( n ) :
    p = 2 ; n -= 1 ; i = 3
    while ( n != 0 ) :
        if ( isPrime ( i ) ) :
            p = p * i
            n -= 1
        i += 1
    return p
def findNextPrime ( n ) :
    nextPrime = n + 2
    while ( True ) :
        if ( isPrime ( nextPrime ) ) :
            break
        nextPrime += 1
    return nextPrime
def fortunateNumber ( n ) :
    p = primorial ( n )
    return findNextPrime ( p ) - p
n = 5
print ( fortunateNumber ( n ) )

Accumulator variables: i, n, nextPrime
Python program:
def testSomeNumbers ( limit , n ) :
    if ( n < 3 ) :
        return
    for a in range ( 1 , limit + 1 ) :
        for b in range ( a , limit + 1 ) :
            pow_sum = pow ( a , n ) + pow ( b , n )
            c = pow ( pow_sum , 1.0 / n )
            c_pow = pow ( int ( c ) , n )
            if ( c_pow == pow_sum ) :
                print ( " Count ▁ example ▁ found " )
                return
    print ( " No ▁ counter ▁ example ▁ within ▁ given ▁ range ▁ and ▁ data " )
testSomeNumbers ( 10 , 3 )

Iterator variables: a, b
Python program:
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b ;
    return gcd ( b % a , a ) ;
def productReduce ( n , num , den ) :
    new_num = 1 ;
    new_den = 1 ;
    for i in range ( n ) :
        new_num = new_num * num [ i ] ;
        new_den = new_den * den [ i ] ;
    GCD = gcd ( new_num , new_den ) ;
    new_num = new_num / GCD ;
    new_den = new_den / GCD ;
    print ( int ( new_num ) , " / " , int ( new_den ) ) ;
n = 3 ;
num = [ 1 , 2 , 5 ] ;
den = [ 2 , 1 , 6 ] ;
productReduce ( n , num , den ) ;

Index/key variables: i
Iterator variables: i
Python program:
import math
def numberofterm ( n , number ) :
    firstnum = math . pow ( 10 , n - 1 )
    lastnum = math . pow ( 10 , n )
    count = 0
    for i in range ( int ( firstnum ) , int ( lastnum ) ) :
        if ( i % number == 0 ) :
            count += 1
    return count
n = 3
num = 7
print ( numberofterm ( n , num ) )

Accumulator variables: count
Iterator variables: i
Python program:
def georgeCantor ( n ) :
    i = 1
    j = 1
    k = 1
    while k < n :
        j += 1
        k += 1
        if k == n :
            break
        while j > 1 and k < n :
            i += 1
            j -= 1
            k += 1
        if k == n :
            break
        i += 1
        k += 1
        if k == n :
            break
        while i > 1 and k < n :
            i -= 1
            j += 1
            k += 1
    print ( " N - th ▁ term ▁ : ▁ % d / % d " % ( i , j ) )
n = 15
georgeCantor ( n )

Accumulator variables: i, j, k
Python program:
def isDivisible ( n ) :
    while ( int ( n / 100 ) ) :
        last_digit = int ( n % 10 )
        n = int ( n / 10 )
        n += last_digit * 3
    return ( n % 29 == 0 )
n = 348
if ( isDivisible ( n ) != 0 ) :
    print ( " Yes " )
else :
    print ( " No " )

Accumulator variables: n
Python program:
def solveEquation ( equation ) :
    n = len ( equation )
    sign = 1
    coeff = 0
    total = 0
    i = 0
    for j in range ( 0 , n ) :
        if ( equation [ j ] == ' + ' or equation [ j ] == ' - ' ) :
            if ( j > i ) :
                total = ( total + sign * int ( equation [ i : j ] ) )
            i = j
        elif ( equation [ j ] == ' x ' ) :
            if ( ( i == j ) or equation [ j - 1 ] == ' + ' ) :
                coeff += sign
            elif ( equation [ j - 1 ] == ' - ' ) :
                coeff = coeff - sign
            else :
                coeff = ( coeff + sign * int ( equation [ i : j ] ) )
            i = j + 1
        elif ( equation [ j ] == ' = ' ) :
            if ( j > i ) :
                total = ( total + sign * int ( equation [ i : j ] ) )
            sign = - 1
            i = j + 1
    if ( i < n ) :
        total = ( total + sign * int ( equation [ i : len ( equation ) ] ) )
    if ( coeff == 0 and total == 0 ) :
        return " Infinite ▁ solutions "
    if ( coeff == 0 and total ) :
        return " No ▁ solution "
    ans = - total / coeff
    return int ( ans )
equation = " x + 5-3 + x = 6 + x - 2"
print ( " x ▁ = ▁ { } " . format ( solveEquation ( equation ) ) )

Index/key variables: j
Accumulator variables: coeff
Iterator variables: j
Python program:
MAX = 100000
def multiply ( x , res , res_size ) :
    carry = 0
    for i in range ( res_size ) :
        prod = res [ i ] * x + carry
        res [ i ] = prod % 10
        carry = prod // 10
    while ( carry ) :
        res [ res_size ] = carry % 10
        carry = carry // 10
        res_size += 1
    return res_size
def power ( x , n ) :
    if ( n == 0 ) :
        print ( "1" )
        return
    res = [ 0 for i in range ( MAX ) ]
    res_size = 0
    temp = x
    while ( temp != 0 ) :
        res [ res_size ] = temp % 10 ;
        res_size += 1
        temp = temp // 10
    for i in range ( 2 , n + 1 ) :
        res_size = multiply ( x , res , res_size )
    print ( x , " ^ " , n , " ▁ = ▁ " , end = " " )
    for i in range ( res_size - 1 , - 1 , - 1 ) :
        print ( res [ i ] , end = " " )
exponent = 100
base = 2
power ( base , exponent )

Index/key variables: i, res_size
Iterator variables: i
Python program:
import math
def check ( n , p ) :
    maximum = - 1
    while ( not ( n % 2 ) ) :
        maximum = max ( maximum , 2 )
        n = int ( n / 2 )
    for i in range ( 3 , int ( math . sqrt ( n ) ) , 2 ) :
        while ( n % i == 0 ) :
            maximum = max ( maximum , i )
            n = int ( n / i )
    if ( n > 2 ) :
        maximum = max ( maximum , n )
    return ( maximum <= p )
n = 24
p = 7
if ( check ( n , p ) ) :
    print ( " yes " )
else :
    print ( " no " )

Iterator variables: i
Python program:
from math import sqrt
def isSquareFree ( n ) :
    if n % 2 == 0 :
        n = n / 2
    if n % 2 == 0 :
        return False
    for i in range ( 3 , int ( sqrt ( n ) + 1 ) ) :
        if n % i == 0 :
            n = n / i
        if n % i == 0 :
            return False
    return True
n = 10
if isSquareFree ( n ) :
    print ( " Yes " )
else :
    print ( " No " )

Iterator variables: i
Python program:
import math
def sumOfSeries ( n ) :
    sum = 0
    for i in range ( 1 , n + 1 ) :
        sum = sum + ( 2 * i - 1 ) * ( 2 * i - 1 )
    return sum
n = 10
print ( sumOfSeries ( n ) )

Iterator variables: i
Python program:
import math
def mean ( arr , n ) :
    sm = 0
    for i in range ( 0 , n ) :
        sm = sm + arr [ i ]
    return sm / n
def SSD ( arr , n ) :
    sm = 0
    for i in range ( 0 , n ) :
        sm = sm + ( arr [ i ] - mean ( arr , n ) ) * ( arr [ i ] - mean ( arr , n ) )
    return ( math . sqrt ( sm / ( n - 1 ) ) )
def sampleError ( arr , n ) :
    return SSD ( arr , n ) / ( math . sqrt ( n ) )
arr = [ 78.53 , 79.62 , 80.25 , 81.05 , 83.21 , 83.46 ]
n = len ( arr )
print ( sampleError ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def seriesSum ( n ) :
    i = 1 ;
    res = 0.0 ;
    sign = True ;
    while ( n > 0 ) :
        n = n - 1 ;
        if ( sign ) :
            sign = False ;
            res = res + ( i + 1 ) / ( i + 2 ) ;
            i = i + 2 ;
        else :
            sign = True ;
            res = res - ( i + 1 ) / ( i + 2 ) ;
            i = i + 2 ;
    return res ;
n = 5 ;
print ( round ( seriesSum ( n ) , 6 ) ) ;

Boolean variables: sign
Python program:
def Mean ( arr , n ) :
    sm = 0
    for i in range ( 0 , n ) :
        sm = sm + arr [ i ]
    return sm // n
def meanAbsoluteDeviation ( arr , n ) :
    absSum = 0
    for i in range ( 0 , n ) :
        absSum = absSum + abs ( arr [ i ] - Mean ( arr , n ) )
    return absSum / n
arr = [ 10 , 15 , 15 , 17 , 18 , 21 ]
n = len ( arr )
print ( meanAbsoluteDeviation ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def isRatioPossible ( lowCost , upCost , lowQuant , upQuant , r ) :
    for i in range ( lowQuant , upQuant + 1 ) :
        ans = i * r
        if ( lowCost <= ans and ans <= upCost ) :
            return True
    return False
lowCost = 14 ; upCost = 30
lowQuant = 5 ; upQuant = 12 ; r = 9
if ( isRatioPossible ( lowCost , upCost , lowQuant , upQuant , r ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Iterator variables: i
Python program:
import sys
def checkTrimorphic ( num ) :
    cube = num * num * num
    while ( num > 0 ) :
        if ( num % 10 != cube % 10 ) :
            return False
        num = int ( num / 10 )
        cube = int ( cube / 10 )
    return True
def nthTrimorphic ( n ) :
    count = 0
    for i in range ( sys . maxsize ) :
        if ( checkTrimorphic ( i ) ) :
            count += 1
        if ( count == n ) :
            return i
if __name__ == ' _ _ main _ _ ' :
    n = 9
    print ( nthTrimorphic ( n ) )

Accumulator variables: count
Iterator variables: i
Python program:
def unitDigitXRaisedY ( x , y ) :
    res = 1
    for i in range ( y ) :
        res = ( res * x ) % 10
    return res
print ( unitDigitXRaisedY ( 4 , 2 ) )

Iterator variables: i
Python program:
def AvgofSquareN ( n ) :
    sum = 0
    for i in range ( 1 , n + 1 ) :
        sum += ( i * i )
    return sum / n
n = 2
print ( AvgofSquareN ( n ) )

Accumulator variables: sum
Iterator variables: i
Python program:
import math
def sumofFactors ( n ) :
    if ( n % 2 != 0 ) :
        return 0
    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 = count + 1
            n = n // i
            if ( i == 2 and count == 1 ) :
                curr_sum = 0
            curr_term = curr_term * i
            curr_sum = curr_sum + curr_term
        res = res * curr_sum
    if ( n >= 2 ) :
        res = res * ( 1 + n )
    return res
n = 18
print ( sumofFactors ( n ) )

Iterator variables: i
Python program:
import math
def LCM ( a , b ) :
    return ( a * b ) // ( math . gcd ( a , b ) )
def lcmOfNumerator ( vect ) :
    lcm = vect [ 0 ] [ 0 ]
    for i in range ( 1 , len ( vect ) ) :
        lcm = LCM ( vect [ i ] [ 0 ] , lcm )
    return lcm
def gcdOfDemoninators ( vect ) :
    gcd = vect [ 0 ] [ 1 ]
    for i in range ( 1 , len ( vect ) ) :
        gcd = math . gcd ( vect [ i ] [ 1 ] , gcd )
    return gcd
def lcmOfRationals ( vect ) :
    print ( lcmOfNumerator ( vect ) , " / " , gcdOfDemoninators ( vect ) , sep = " " )
vect = [ ]
vect . append ( ( 2 , 7 ) )
vect . append ( ( 3 , 14 ) )
vect . append ( ( 5 , 3 ) )
lcmOfRationals ( vect )

Index/key variables: i
Iterator variables: i
Python program:
import math
def sumofoddFactors ( n ) :
    res = 1
    while n % 2 == 0 :
        n = n // 2
    for i in range ( 3 , int ( math . sqrt ( n ) + 1 ) ) :
        count = 0
        curr_sum = 1
        curr_term = 1
        while n % i == 0 :
            count += 1
            n = n // i
            curr_term *= i
            curr_sum += curr_term
        res *= curr_sum
    if n >= 2 :
        res *= ( 1 + n )
    return res
n = 30
print ( sumofoddFactors ( n ) )

Accumulator variables: count, curr_sum, curr_term, res
Iterator variables: i
Python program:
def countSolutions ( n , val ) :
    total = 0
    if n == 1 and val >= 0 :
        return 1
    for i in range ( val + 1 ) :
        total += countSolutions ( n - 1 , val - i )
    return total
n = 5
val = 20
print ( countSolutions ( n , val ) )

Accumulator variables: total
Iterator variables: i
Python program:
N = 6 ;
def fib ( f , n ) :
    f [ 0 ] = 0 ;
    f [ 1 ] = 1 ;
    for i in range ( 2 , n + 1 ) :
        f [ i ] = f [ i - 1 ] + f [ i - 2 ] ;
def fibcoef ( fc , f , n ) :
    for i in range ( n + 1 ) :
        fc [ i ] [ 0 ] = 1 ;
    for i in range ( 1 , n + 1 ) :
        for j in range ( 1 , i + 1 ) :
            k = j ;
            while ( k > 0 ) :
                k -= 1 ;
                fc [ i ] [ j ] *= f [ k ] ;
            k = 1 ;
            while ( ( j + 1 ) != k ) :
                fc [ i ] [ j ] /= f [ k ] ;
                k += 1 ;
def printFibonomialTriangle ( n ) :
    f = [ 0 ] * ( N + 1 ) ;
    fib ( f , n ) ;
    dp = [ [ 0 for x in range ( N + 1 ) ] for y in range ( N + 1 ) ] ;
    for i in range ( n + 1 ) :
        dp [ i ] [ 0 ] = 1 ;
        dp [ i ] [ i ] = 1 ;
    for i in range ( 1 , n + 1 ) :
        for j in range ( 1 , i ) :
            dp [ i ] [ j ] = ( f [ i - j + 1 ] * dp [ i - 1 ] [ j - 1 ] + f [ j - 1 ] * dp [ i - 1 ] [ j ] ) ;
    for i in range ( n + 1 ) :
        for j in range ( i + 1 ) :
            print ( dp [ i ] [ j ] , end = " ▁ " ) ;
        print ( " " ) ;
n = 6 ;
printFibonomialTriangle ( n ) ;

Index/key variables: i, j, k
Iterator variables: i, j
Python program:
import math
def sumofNterm ( a , d , b , r , n ) :
    sum = 0
    for i in range ( 1 , n + 1 ) :
        sum += ( ( a + ( i - 1 ) * d ) * ( b * math . pow ( r , i - 1 ) ) )
    return int ( sum )
a = 1
d = 1
b = 2
r = 2
n = 3
print ( sumofNterm ( a , d , b , r , n ) )

Accumulator variables: sum
Iterator variables: i
Python program:
def sumOfTheSeries ( n ) :
    sum = 0
    for i in range ( 0 , n + 1 ) :
        k = 2
        for j in range ( 1 , i + 1 ) :
            sum = sum + k ;
            k = k + 2
    return sum ;
n = 5
ans = sumOfTheSeries ( n ) ;
print ( ans )

Iterator variables: i, j
Python program:
import math
def Series ( x , n ) :
    sum = 1
    term = 1
    y = 2
    for i in range ( 1 , n ) :
        fct = 1
        for j in range ( 1 , y + 1 ) :
            fct = fct * j
        term = term * ( - 1 )
        m = term * math . pow ( x , y ) / fct
        sum = sum + m
        y += 2
    return sum
x = 9
n = 10
print ( ' % .4f ' % Series ( x , n ) )

Accumulator variables: y
Iterator variables: i, j
Python program:
def Series ( x , n ) :
    sum = 1
    term = 1
    fct = 1
    p = 1
    multi = 1
    for i in range ( 1 , n ) :
        fct = fct * multi * ( multi + 1 )
        p = p * x * x
        term = ( - 1 ) * term
        multi += 2
        sum = sum + ( term * p ) / fct
    return sum
x = 9
n = 10
print ( ' % .4f ' % Series ( x , n ) )

Accumulator variables: multi
Iterator variables: i
Python program:
def two_factor ( n ) :
    twocount = 0
    while n % 2 == 0 :
        twocount += 1
        n = int ( n / 2 )
    return twocount
def five_factor ( n ) :
    fivecount = 0
    while n % 5 == 0 :
        fivecount += 1
        n = int ( n / 5 )
    return fivecount
def find_con_zero ( arr , n ) :
    twocount = 0
    fivecount = 0
    for i in range ( n ) :
        twocount += two_factor ( arr [ i ] )
        fivecount += five_factor ( arr [ i ] )
    if twocount < fivecount :
        return twocount
    else :
        return fivecount
arr = [ 100 , 10 , 5 , 25 , 35 , 14 ]
n = 6
print ( find_con_zero ( arr , n ) )

Index/key variables: i
Accumulator variables: fivecount, twocount
Iterator variables: i
Python program:
def first ( a , b , c ) :
    a %= b
    for i in range ( 1 , b + 1 ) :
        a = a * 10
        if int ( a / b ) == c :
            return i
        a %= b
    return - 1
a = 1
b = 4
c = 5
print ( first ( a , b , c ) )

Accumulator variables: a
Iterator variables: i
Python program:
def sumOfTheSeries ( n ) :
    sum = 0
    for i in range ( 1 , n + 1 ) :
        k = 1
        for j in range ( 1 , i + 1 ) :
            sum += k
            k += 2
    return sum
n = 5
print ( " Sum ▁ = " , sumOfTheSeries ( n ) )

Accumulator variables: k, sum
Iterator variables: i, j
Python program:
def checksum ( n ) :
    if n == 0 :
        print ( " - 1 ▁ 0 ▁ 1" )
        return 0
    inc = 0
    if n > 0 :
        inc = 1
    else :
        inc = - 1
    for i in range ( 0 , n - 1 , inc ) :
        if i + i + 1 + i + 2 == n :
            print ( i , " ▁ " , i + 1 , " ▁ " , i + 2 )
            return 0
    print ( " - 1" )
n = 6
checksum ( n )

Iterator variables: i
Python program:
def printbinomial ( max ) :
    for m in range ( max + 1 ) :
        print ( ' % ▁ 2d ' % m , end = ' ▁ ' )
        binom = 1
        for x in range ( m + 1 ) :
            if m != 0 and x != 0 :
                binom = binom * ( m - x + 1 ) / x
            print ( ' % ▁ 4d ' % binom , end = ' ▁ ' )
        print ( " " , end = ' ' )
max = 10
printbinomial ( max )

Iterator variables: m, x
Python program:
import math
def maxPrimeFactors ( n ) :
    maxPrime = - 1
    while n % 2 == 0 :
        maxPrime = 2
    while n % 3 == 0 :
        maxPrime = 3
        n = n / 3
    for i in range ( 5 , int ( math . sqrt ( n ) ) + 1 , 6 ) :
        while n % i == 0 :
            maxPrime = i
            n = n / i
        while n % ( i + 2 ) == 0 :
            maxPrime = i + 2
            n = n / ( i + 2 )
    if n > 4 :
        maxPrime = n
    return int ( maxPrime )
n = 15
print ( maxPrimeFactors ( n ) )
n = 25698751364526
print ( maxPrimeFactors ( n ) )

Iterator variables: i
Python program:
def evenPowerSum ( n ) :
    sum = 0 ;
    for i in range ( 1 , n + 1 ) :
        j = 2 * i ;
        sum = sum + ( j * j * j * j ) ;
    return sum ;
n = 5 ;
print ( evenPowerSum ( n ) ) ;

Iterator variables: i
Python program:
MAX = 501
def balancedprime ( n ) :
    prime = [ True ] * ( MAX + 1 )
    p = 2
    while p * p <= MAX :
        if prime [ p ] == True :
            i = p * 2
            while i <= MAX :
                prime [ i ] = False
                i = i + p
        p = p + 1
    v = list ( )
    p = 3
    while p <= MAX :
        if prime [ p ] :
            v . append ( p )
        p = p + 2
    count = 0
    i = 1
    for i in range ( len ( v ) ) :
        if v [ i ] == ( v [ i + 1 ] + v [ i - 1 ] ) / 2 :
            count += 1
        if count == n :
            return v [ i ]
n = 4
print ( balancedprime ( n ) )

Index/key variables: i, p
Accumulator variables: count, v
Iterator variables: i