dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
MAX = 100001 ;
factor = [ 0 ] * MAX ;
def generatePrimeFactors ( ) :
    factor [ 1 ] = 1 ;
    for i in range ( 2 , MAX ) :
        factor [ i ] = i ;
    i = 4
    while ( i < MAX ) :
        factor [ i ] = 2 ;
        i += 2 ;
    i = 3 ;
    while ( i * i < MAX ) :
        if ( factor [ i ] == i ) :
            j = i * i ;
            while ( j < MAX ) :
                if ( factor [ j ] == j ) :
                    factor [ j ] = i ;
                j += i ;
        i += 1 ;
def calculateNoOFactors ( n ) :
    if ( n == 1 ) :
        return 1 ;
    ans = 1 ;
    dup = factor [ n ] ;
    c = 1 ;
    j = int ( n / factor [ n ] ) ;
    while ( j != 1 ) :
        if ( factor [ j ] == dup ) :
            c += 1 ;
        else :
            dup = factor [ j ] ;
            ans = ans * ( c + 1 ) ;
            c = 1 ;
        j = int ( j / factor [ j ] ) ;
    ans = ans * ( c + 1 ) ;
    return ans ;
def smallest ( n ) :
    i = 1 ;
    while ( True ) :
        if ( calculateNoOFactors ( i ) >= n ) :
            return i ;
        i += 1 ;
generatePrimeFactors ( ) ;
n = 4 ;
print ( smallest ( n ) ) ;

Index/key variables: i, j, n
Accumulator variables: c
Iterator variables: i
Python program:
def squaresum ( n ) :
    sm = 0
    for i in range ( 1 , n + 1 ) :
        sm = sm + ( i * i )
    return sm
n = 4
print ( squaresum ( n ) )

Iterator variables: i
Python program:
def isPrime ( n ) :
    i = 2
    while ( i * i <= n ) :
        if ( n % i == 0 ) :
            return False
        i += 1
    return True
def minimumSum ( n ) :
    if ( isPrime ( n ) ) :
        return 1
    if ( n % 2 == 0 ) :
        return 2
    if ( isPrime ( n - 2 ) ) :
        return 2
    return 3
n = 27
print ( minimumSum ( n ) )

Accumulator variables: i
Python program:
c = [ 0 ] * 100 ;
def coef ( n ) :
    c [ 0 ] = 1 ;
    for i in range ( n ) :
        c [ 1 + i ] = 1 ;
        for j in range ( i , 0 , - 1 ) :
            c [ j ] = c [ j - 1 ] - c [ j ] ;
        c [ 0 ] = - c [ 0 ] ;
def isPrime ( n ) :
    coef ( n ) ;
    c [ 0 ] = c [ 0 ] + 1 ;
    c [ n ] = c [ n ] - 1 ;
    i = n ;
    while ( i > - 1 and c [ i ] % n == 0 ) :
        i = i - 1 ;
    return True if i < 0 else False ;
n = 37 ;
if ( isPrime ( n ) ) :
    print ( " Prime " ) ;
else :
    print ( " Not ▁ Prime " ) ;

Index/key variables: i, j, n
Iterator variables: i, j
Python program:
import math
def leyland ( n ) :
    ans = [ ]
    x = 2
    y = 2
    while x <= n :
        y = 2
        while y <= x :
            temp = pow ( x , y ) + pow ( y , x )
            ans . append ( temp ) ;
            y = y + 1
        x = x + 1
    ans . sort ( ) ;
    i = 0
    while i < n :
        print ( ans [ i ] , end = " ▁ " )
        i = i + 1
n = 6
leyland ( n )

Index/key variables: i
Accumulator variables: ans
Python program:
def kthgroupsum ( k ) :
    cur = int ( ( k * ( k - 1 ) ) + 1 )
    sum = 0
    while k :
        sum += cur
        cur += 2
        k = k - 1
    return sum
k = 3
print ( kthgroupsum ( k ) )

Accumulator variables: cur, sum
Python program:
def term ( n ) :
    ans = 0
    for i in range ( 1 , n + 1 ) :
        ans = ans + i
    return ans
n = 4
print ( term ( n ) )

Iterator variables: i
Python program:
def sum ( x , n ) :
    total = 1.0
    multi = x
    for i in range ( 1 , n + 1 ) :
        total = total + multi / i
        multi = multi * x
    return total
x = 2
n = 5
print ( round ( sum ( x , n ) , 2 ) )

Iterator variables: i
Python program:
def countDigits ( n ) :
    c = 0
    while ( n != 0 ) :
        c += 1
        n = int ( n / 10 )
    return c
def isDeserium ( x ) :
    temp = x
    p = countDigits ( x )
    sum = 0
    while ( x != 0 ) :
        digit = int ( x % 10 )
        sum += pow ( digit , p )
        p -= 1
        x = int ( x / 10 )
    return ( sum == temp )
x = 135
if ( isDeserium ( x ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Accumulator variables: c, p, sum
Python program:
def mean ( arr , n ) :
    sum = 0 ;
    for i in range ( n ) :
        sum = sum + arr [ i ] ;
    mean = sum / n ;
    return mean ;
def sd ( arr , n ) :
    sum = 0 ;
    for i in range ( n ) :
        sum = sum + ( ( arr [ i ] - mean ( arr , n ) ) * ( arr [ i ] - mean ( arr , n ) ) ) ;
    sdd = sum / n ;
    return sdd ;
def combinedVariance ( arr1 , arr2 , n , m ) :
    mean1 = mean ( arr1 , n ) ;
    mean2 = mean ( arr2 , m ) ;
    print ( " Mean1 : ▁ " , round ( mean1 , 2 ) , " ▁ mean2 : ▁ " , round ( mean2 , 2 ) ) ;
    sd1 = sd ( arr1 , n ) ;
    sd2 = sd ( arr2 , m ) ;
    print ( " StandardDeviation1 : ▁ " , round ( sd1 , 2 ) , " ▁ StandardDeviation2 : ▁ " , round ( sd2 , 2 ) ) ;
    combinedMean = ( n * mean1 + m * mean2 ) / ( n + m ) ;
    print ( " Combined ▁ Mean : ▁ " , round ( combinedMean , 2 ) ) ;
    d1_square = ( ( mean1 - combinedMean ) * ( mean1 - combinedMean ) ) ;
    d2_square = ( ( mean2 - combinedMean ) * ( mean2 - combinedMean ) ) ;
    print ( " d1 ▁ square : ▁ " , round ( d1_square , 2 ) , " ▁ d2 _ square : ▁ " , round ( d2_square , 2 ) ) ;
    combinedVar = ( n * ( sd1 + d1_square ) + m * ( sd2 + d2_square ) ) / ( n + m ) ;
    print ( " Combined ▁ Variance : ▁ " , round ( combinedVar , 2 ) ) ;
arr1 = [ 23 , 45 , 34 , 78 , 12 , 76 , 34 ] ;
arr2 = [ 65 , 67 , 34 , 23 , 45 ] ;
n = len ( arr1 ) ;
m = len ( arr2 ) ;
combinedVariance ( arr1 , arr2 , n , m ) ;

Index/key variables: i
Iterator variables: i
Python program:
def checkDivisibility ( num ) :
    length = len ( num )
    if ( length == 1 and num [ 0 ] == '0' ) :
        return True
    if ( length % 3 == 1 ) :
        num = str ( num ) + "00"
        length += 2
    elif ( length % 3 == 2 ) :
        num = str ( num ) + "0"
        length += 1
    sum = 0
    p = 1
    for i in range ( length - 1 , - 1 , - 1 ) :
        group = 0
        group += ord ( num [ i ] ) - ord ( '0' )
        i -= 1
        group += ( ord ( num [ i ] ) - ord ( '0' ) ) * 10
        i -= 1
        group += ( ord ( num [ i ] ) - ord ( '0' ) ) * 100
        sum = sum + group * p
        p *= ( - 1 )
    sum = abs ( sum )
    return ( sum % 13 == 0 )
if __name__ == " _ _ main _ _ " :
    number = "83959092724"
    if ( checkDivisibility ( number ) ) :
        print ( number , " is ▁ divisible ▁ by ▁ 13 . " )
    else :
        print ( number , " is ▁ not ▁ divisible ▁ by ▁ 13 . " )

Index/key variables: i
Accumulator variables: group, p
Iterator variables: i
Python program:
import math
def modularEquation ( a , b ) :
    if ( a < b ) :
        print ( " No ▁ solution ▁ possible ▁ " )
        return
    if ( a == b ) :
        print ( " Infinite ▁ Solution ▁ possible ▁ " )
        return
    count = 0
    n = a - b
    y = ( int ) ( math . sqrt ( a - b ) )
    for i in range ( 1 , y + 1 ) :
        if ( n % i == 0 ) :
            if ( n / i > b ) :
                count = count + 1
            if ( i > b ) :
                count = count + 1
    if ( y * y == n and y > b ) :
        count = count - 1
    print ( count )
a = 21
b = 5
modularEquation ( a , b )

Iterator variables: i
Python program:
def sumSquare ( n ) :
    s = dict ( )
    for i in range ( n ) :
        if i * i > n :
            break
        s [ i * i ] = 1
        if ( n - i * i ) in s . keys ( ) :
            print ( ( n - i * i ) ** ( 1 / 2 ) , " ^ 2 ▁ + " , i , " ^ 2" )
            return True
    return False
n = 1
if n == 1 :
    print ( '0 ^ 2 ▁ + ▁ 1 ^ 2' )
elif ( sumSquare ( n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Iterator variables: i
Python program:
def judgeSquareSum ( n ) :
    i = 2 ;
    while ( i * i <= n ) :
        count = 0 ;
        if ( n % i == 0 ) :
            while ( n % i == 0 ) :
                count += 1 ;
                n = int ( n / i ) ;
            if ( i % 4 == 3 and count % 2 != 0 ) :
                return False ;
        i += 1 ;
    return n % 4 != 3 ;
n = 17 ;
if ( judgeSquareSum ( n ) ) :
    print ( " Yes " ) ;
else :
    print ( " No " ) ;

Accumulator variables: count, i
Python program:
def countDigitOne ( n ) :
    countr = 0 ;
    i = 1 ;
    while ( i <= n ) :
        divider = i * 10 ;
        countr += ( int ( n / divider ) * i + min ( max ( n % divider - i + 1 , 0 ) , i ) ) ;
        i *= 10 ;
    return countr ;
n = 13 ;
print ( countDigitOne ( n ) ) ;
n = 113 ;
print ( countDigitOne ( n ) ) ;
n = 205 ;
print ( countDigitOne ( n ) ) ;

Accumulator variables: countr, i
Python program:
def isPrime ( c ) :
    return ( c == '2' or c == '3' or c == '5' or c == '7' )
def decrease ( s , i ) :
    if ( s [ i ] <= '2' ) :
        s . pop ( i )
        s [ i ] = '7'
    elif ( s [ i ] == '3' ) :
        s [ i ] = '2'
    elif ( s [ i ] <= '5' ) :
        s [ i ] = '3'
    elif ( s [ i ] <= '7' ) :
        s [ i ] = '5'
    else :
        s [ i ] = '7'
def primeDigits ( s ) :
    s = [ i for i in s ]
    i = 0
    while i < len ( s ) :
        if ( isPrime ( s [ i ] ) == False ) :
            while ( s [ i ] <= '2' and i >= 0 ) :
                i -= 1
            if ( i < 0 ) :
                i = 0
                decrease ( s , i )
            else :
                decrease ( s , i )
            for j in range ( i + 1 , len ( s ) ) :
                s [ j ] = '7'
            break
        i += 1
    return " " . join ( s )
s = "45"
print ( primeDigits ( s ) )
s = "1000"
print ( primeDigits ( s ) )
s = "7721"
print ( primeDigits ( s ) )
s = "7221"
print ( primeDigits ( s ) )
s = "74545678912345689748593275897894708927680"
print ( primeDigits ( s ) )

Index/key variables: i, j
Iterator variables: j
Python program:
import math as mt
def greatest ( s ) :
    n = len ( s )
    a = [ 0 for i in range ( n ) ]
    Sum = 0
    for i in range ( n ) :
        a [ i ] = ord ( s [ i ] ) - ord ( '0' )
        Sum += a [ i ]
        if ( a [ n - 2 ] % 2 != 0 or ( Sum - a [ n - 1 ] ) % 3 != 0 ) :
            print ( " - 1" )
        else :
            print ( n )
    else :
        re = Sum % 3
        dell = - 1
        flag = 0
        for i in range ( n - 1 ) :
            if ( ( a [ i ] ) % 3 == re ) :
                if ( a [ i + 1 ] > a [ i ] ) :
                    dell = i
                    flag = 1
                    break
                else :
                    dell = i
        if ( flag == 0 ) :
            if ( a [ n - 2 ] % 2 == 0 and re == a [ n - 1 ] % 3 ) :
                dell = n - 1
        if ( dell == - 1 ) :
            print ( " - 1" )
        else :
            print ( dell + 1 )
s = "7510222"
greatest ( s )

Index/key variables: i
Accumulator variables: Sum
Iterator variables: i
Python program:
def divisible ( num ) :
    n = len ( num )
    sum_ = 0
    for i in range ( n ) :
        sum_ += int ( num [ i ] )
    if ( sum_ % 3 == 0 ) :
        return 0
    if ( n == 1 ) :
        return - 1
    for i in range ( n ) :
        if ( sum_ % 3 == int ( num [ i ] ) % 3 ) :
            return 1
    if ( n == 2 ) :
        return - 1
    return 2
if __name__ == ' _ _ main _ _ ' :
    num = "1234"
    print ( divisible ( num ) )

Index/key variables: i
Accumulator variables: sum_
Iterator variables: i
Python program:
n = 3
def dotProduct ( vect_A , vect_B ) :
    product = 0
    for i in range ( 0 , n ) :
        product = product + vect_A [ i ] * vect_B [ i ]
    return product
def crossProduct ( vect_A , vect_B , cross_P ) :
    cross_P . append ( vect_A [ 1 ] * vect_B [ 2 ] - vect_A [ 2 ] * vect_B [ 1 ] )
    cross_P . append ( vect_A [ 2 ] * vect_B [ 0 ] - vect_A [ 0 ] * vect_B [ 2 ] )
    cross_P . append ( vect_A [ 0 ] * vect_B [ 1 ] - vect_A [ 1 ] * vect_B [ 0 ] )
if __name__ == ' _ _ main _ _ ' :
    vect_A = [ 3 , - 5 , 4 ]
    vect_B = [ 2 , 6 , 5 ]
    cross_P = [ ]
    print ( " Dot ▁ product : " , end = " ▁ " )
    print ( dotProduct ( vect_A , vect_B ) )
    print ( " Cross ▁ product : " , end = " ▁ " )
    crossProduct ( vect_A , vect_B , cross_P )
    for i in range ( 0 , n ) :
        print ( cross_P [ i ] , end = " ▁ " )

Index/key variables: i
Iterator variables: i
Python program:
MAX = 1000001
factor = [ 0 ] * MAX
def cal_factor ( ) :
    factor [ 1 ] = 1
    for i in range ( 2 , MAX ) :
        factor [ i ] = i
    for i in range ( 4 , MAX , 2 ) :
        factor [ i ] = 2
    i = 3
    while i * i < MAX :
        if ( factor [ i ] == i ) :
            for j in range ( i * i , MAX , i ) :
                if ( factor [ j ] == j ) :
                    factor [ j ] = i
        i += 1
def no_of_representations ( a , n ) :
    count = 0
    for i in range ( n ) :
        temp = a [ i ]
        flag = 0
        while ( factor [ temp ] != 1 ) :
            flag = - 1
            count += 1
            temp = temp // factor [ temp ]
        count += flag
    return count
if __name__ == " _ _ main _ _ " :
    cal_factor ( )
    a = [ 4 , 4 , 4 ]
    n = len ( a )
    print ( no_of_representations ( a , n ) )

Index/key variables: i, j, temp
Accumulator variables: count
Iterator variables: i, j
Python program:
def countSubSeq ( A , N , M ) :
    ans = 0
    h = [ 0 ] * M
    for i in range ( 0 , N ) :
        A [ i ] = A [ i ] % M
        h [ A [ i ] ] = h [ A [ i ] ] + 1
    for i in range ( 0 , M ) :
        for j in range ( i , M ) :
            rem = ( M - ( i + j ) % M ) % M
            if ( rem < j ) :
                continue
            if ( i == j and rem == j ) :
                ans = ans + h [ i ] * ( h [ i ] - 1 ) * ( h [ i ] - 2 ) / 6
            elif ( i == j ) :
                ans = ans + ( h [ i ] * ( h [ i ] - 1 ) * h [ rem ] / 2 )
            elif ( i == rem ) :
                ans = ans + h [ i ] * ( h [ i ] - 1 ) * h [ j ] / 2
            elif ( rem == j ) :
                ans = ans + h [ j ] * ( h [ j ] - 1 ) * h [ i ] / 2
            else :
                ans = ans + h [ i ] * h [ j ] * h [ rem ]
        return ans
M = 3 ;
A = [ 1 , 2 , 4 , 3 ]
N = len ( A )
print ( countSubSeq ( A , N , M ) )

Index/key variables: i, j, rem
Iterator variables: i, j
Python program:
def findTerm ( n ) :
    if n == 1 :
        return n
    else :
        term = 7
        for i in range ( 2 , n + 1 ) :
            term = term * 2 + ( i - 1 ) ;
    return term ;
print ( findTerm ( 5 ) )

Iterator variables: i
Python program:
def findNumber ( n ) :
    n -= 1
    i = 1
    while n >= 0 :
        n -= i
        i += 1
    return ( n + i )
n = 3
print ( findNumber ( n ) )

Accumulator variables: i, n
Python program:
def harmonicMean ( arr , n ) :
    sm = 0
    for i in range ( 0 , n ) :
        sm = sm + ( 1 ) / arr [ i ] ;
    return n / sm
arr = [ 13.5 , 14.5 , 14.8 , 15.2 , 16.1 ] ;
n = len ( arr )
print ( harmonicMean ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def harmonicMean ( arr , freq , n ) :
    sm = 0
    frequency_sum = 0
    for i in range ( 0 , n ) :
        sm = sm + freq [ i ] / arr [ i ]
        frequency_sum = frequency_sum + freq [ i ]
    return ( round ( frequency_sum / sm , 4 ) )
num = [ 13 , 14 , 15 , 16 , 17 ]
freq = [ 2 , 5 , 13 , 7 , 3 ]
n = len ( num )
print ( harmonicMean ( num , freq , n ) )

Index/key variables: i
Iterator variables: i
Python program:
import math
def findArmstrong ( low , high ) :
    for i in range ( low + 1 , high ) :
        x = i
        n = 0
        while ( x != 0 ) :
            x = x / 10
            n = n + 1
        pow_sum = 0
        x = i
        while ( x != 0 ) :
            digit = x % 10
            pow_sum = pow_sum + math . pow ( digit , n )
            x = x / 10
        if ( pow_sum == i ) :
            print ( str ( i ) + " ▁ " ) ,
num1 = 100
num2 = 400
findArmstrong ( num1 , num2 )
print ( " " )

Iterator variables: i
Python program:
import random
import math
def primeFactors ( n , factors ) :
    if ( n % 2 == 0 ) :
        factors . append ( 2 )
    while ( n % 2 == 0 ) :
        n = n // 2
    for i in range ( 3 , int ( math . sqrt ( n ) ) + 1 , 2 ) :
        if ( n % i == 0 ) :
            factors . append ( i )
        while ( n % i == 0 ) :
            n = n // i
    if ( n > 2 ) :
        factors . append ( n )
    return factors
def power ( n , r , q ) :
    total = n
    for i in range ( 1 , r ) :
        total = ( total * n ) % q
    return total
def lucasTest ( n ) :
    if ( n == 1 ) :
        return " neither ▁ prime ▁ nor ▁ composite "
    if ( n == 2 ) :
        return " prime "
    if ( n % 2 == 0 ) :
        return " composite1"
    factors = [ ]
    factors = primeFactors ( n - 1 , factors )
    rand = [ i + 2 for i in range ( n - 3 ) ]
    random . shuffle ( rand )
    for i in range ( n - 2 ) :
        a = rand [ i ]
        if ( power ( a , n - 1 , n ) != 1 ) :
            return " composite "
        flag = True
        for k in range ( len ( factors ) ) :
            if ( power ( a , ( n - 1 ) // factors [ k ] , n ) == 1 ) :
                flag = False
                break
        if ( flag ) :
            return " prime "
    return " probably ▁ composite "
if __name__ == " _ _ main _ _ " :
    print ( str ( 7 ) + " ▁ is ▁ " + lucasTest ( 7 ) )
    print ( str ( 9 ) + " ▁ is ▁ " + lucasTest ( 9 ) )
    print ( str ( 37 ) + " ▁ is ▁ " + lucasTest ( 37 ) )

Index/key variables: i, k
Accumulator variables: factors
Iterator variables: i, k
Boolean variables: flag
Python program:
def gcdMax ( a , b , n , N ) :
    cnt = [ 0 ] * N
    first = [ 0 ] * N
    second = [ 0 ] * N
    for i in range ( n ) :
        cnt [ a [ i ] ] = 1
    for i in range ( 1 , N ) :
        for j in range ( i , N , i ) :
            if ( cnt [ j ] ) :
                first [ i ] = max ( first [ i ] , j )
    cnt = [ 0 ] * N
    for i in range ( n ) :
        cnt [ b [ i ] ] = 1
    for i in range ( 1 , N ) :
        for j in range ( i , N , i ) :
            if ( cnt [ j ] > 0 ) :
                second [ i ] = max ( second [ i ] , j )
    i = N - 1
    while i >= 0 :
        if ( first [ i ] > 0 and second [ i ] > 0 ) :
            break
        i -= 1
    print ( str ( first [ i ] ) + " ▁ " + str ( second [ i ] ) )
if __name__ == " _ _ main _ _ " :
    a = [ 3 , 1 , 4 , 2 , 8 ]
    b = [ 5 , 2 , 12 , 8 , 3 ]
    n = len ( a )
    N = 20
    gcdMax ( a , b , n , N )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def printPierpont ( n ) :
    arr = [ False ] * ( n + 1 ) ;
    two = 1 ;
    three = 1 ;
    while ( two + 1 < n ) :
        arr [ two ] = True ;
        while ( two * three + 1 < n ) :
            arr [ three ] = True ;
            arr [ two * three ] = True ;
            three *= 3 ;
        three = 1 ;
        two *= 2 ;
    v = [ ] ;
    for i in range ( n ) :
        if ( arr [ i ] ) :
            v . append ( i + 1 ) ;
    arr1 = [ False ] * ( len ( arr ) ) ;
    p = 2 ;
    while ( p * p < n ) :
        if ( arr1 [ p ] == False ) :
            for i in range ( p * 2 , n , p ) :
                arr1 [ i ] = True ;
        p += 1 ;
    for i in range ( len ( v ) ) :
        if ( not arr1 [ v [ i ] ] ) :
            print ( v [ i ] , end = " ▁ " ) ;
n = 200 ;
printPierpont ( n ) ;

Index/key variables: i, p, three, two
Accumulator variables: v
Iterator variables: i
Python program:
def print_result ( a , n , k , m ) :
    v = [ [ ] for i in range ( m ) ]
    for i in range ( 0 , n ) :
        rem = a [ i ] % m
        v [ rem ] . append ( a [ i ] )
        if ( len ( v [ rem ] ) == k ) :
            for j in range ( 0 , k ) :
                print ( v [ rem ] [ j ] , end = " ▁ " )
            return
    print ( - 1 )
if __name__ == ' _ _ main _ _ ' :
    a = [ 1 , 8 , 4 ]
    n = len ( a )
    print_result ( a , n , 2 , 3 )

Index/key variables: i, j, rem
Iterator variables: i, j
Python program:
def PrimeDigitNumber ( N , size ) :
    ans = [ " " ] * size
    ns = 0 ;
    small = 0 ;
    p = [ 0 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 0 , 0 ]
    prevprime = [ 0 , 0 , 0 , 2 , 3 , 3 , 5 , 5 , 7 , 7 ]
    if ( size == 1 ) :
        ans [ 0 ] = prevprime [ ord ( N [ 0 ] ) - ord ( '0' ) ] + ord ( '0' ) ;
        ans [ 1 ] = ' ' ;
        return ' ' . join ( ans ) ;
    if ( N [ 0 ] == '1' ) :
        for i in range ( size - 1 ) :
            ans [ i ] = '7'
        ans [ size - 1 ] = ' ' ;
        return ' ' . join ( ans )
    i = 0
    while ( i < size and small == 0 ) :
        if ( p [ ord ( N [ i ] ) - ord ( '0' ) ] == 1 ) :
            ans [ ns ] = N [ i ]
            ns += 1
        else :
            if ( p [ ord ( N [ i ] ) - ord ( '0' ) ] == 0 and prevprime [ ord ( N [ i ] ) - ord ( '0' ) ] != 0 ) :
                ans [ ns ] = prevprime [ ord ( N [ i ] ) - ord ( '0' ) ] + ord ( '0' ) ;
                small = 1
                ns += 1
            elif ( p [ ord ( N [ i ] ) - ord ( '0' ) ] == 0 and prevprime [ ord ( N [ i ] ) - ord ( '0' ) ] == 0 ) :
                j = i ;
                while ( j > 0 and p [ ord ( N [ j ] ) - ord ( '0' ) ] == 0 and prevprime [ ord ( N [ j ] ) - ord ( '0' ) ] == 0 ) :
                    ans [ j ] = N [ j ] = '7' ;
                    N [ j - 1 ] = prevprime [ ord ( N [ j - 1 ] ) - ord ( '0' ) ] + ord ( '0' ) ;
                    ans [ j - 1 ] = N [ j - 1 ] ;
                    small = 1 ;
                    j -= 1
                i = ns
        i += 1
    if ( small == 0 ) :
        if ( prevprime [ ord ( N [ size - 1 ] ) - ord ( '0' ) ] + ord ( '0' ) != ord ( '0' ) ) :
            ans [ size - 1 ] = prevprime [ ord ( N [ size - 1 ] ) - ord ( '0' ) ] + ord ( '0' ) ;
        else :
            j = size - 1 ;
            while ( j > 0 and prevprime [ ord ( N [ j ] ) - ord ( '0' ) ] == 0 ) :
                ans [ j ] = N [ j ] = '7' ;
                N [ j - 1 ] = prevprime [ ord ( N [ j - 1 ] ) - ord ( '0' ) ] + ord ( '0' ) ;
                ans [ j - 1 ] = N [ j - 1 ] ;
                small = 1 ;
                j -= 1
    while ( ns < size ) :
        ans [ ns ] = '7'
        ns += 1
    ans [ ns ] = ' ' ;
    k = 0 ;
    while ( ans [ k ] == '0' ) :
        k += 1
    return ( ans + k )
if __name__ == " _ _ main _ _ " :
    N = "1000" ;
    size = len ( N ) ;
    print ( PrimeDigitNumber ( N , size ) )

Index/key variables: i, j, k, ns
Iterator variables: i
Python program:
def smallestX ( n ) :
    temp = [ 0 ] * 10
    if ( n == 0 ) :
        return - 1
    count = 0
    x = 1
    while ( count < 10 ) :
        y = x * n
        while ( y > 0 ) :
            if ( temp [ y % 10 ] == 0 ) :
                count += 1
                temp [ y % 10 ] = 1
            y = int ( y / 10 )
        x += 1
    return x - 1
if __name__ == ' _ _ main _ _ ' :
    n = 5
    print ( smallestX ( n ) )

Accumulator variables: count, x
Python program:
def digSum ( n ) :
    sum = 0 ;
    rem = 0 ;
    while ( n ) :
        rem = n % 10 ;
        sum = sum + rem ;
        n = int ( n / 10 ) ;
    return sum ;
def findX ( n ) :
    for i in range ( n + 1 ) :
        if ( i + digSum ( i ) == n ) :
            return i ;
    return - 1 ;
n = 43 ;
print ( " x ▁ = ▁ " , findX ( n ) ) ;

Iterator variables: i
Python program:
def complement ( number ) :
    for i in range ( 0 , len ( number ) ) :
        if ( number [ i ] != ' . ' ) :
            a = 9 - int ( number [ i ] )
            number = ( number [ : i ] + str ( a ) + number [ i + 1 : ] )
    print ( "9 ' s ▁ complement ▁ is ▁ : ▁ " , number )
if __name__ == ' _ _ main _ _ ' :
    number = "345.45"
    complement ( number )

Index/key variables: i
Iterator variables: i
Python program:
def countWays ( n ) :
    count = 0
    i = 1
    while ( ( i * i ) < n ) :
        if ( n % i == 0 ) :
            count += 1
        i += 1
    return count
n = 12
print ( countWays ( n ) )

Accumulator variables: count, i
Python program:
import math
def isDigitPresent ( m , Hash ) :
    while ( m ) :
        if ( Hash [ m % 10 ] ) :
            return True
        m = m // 10
    return False
def countDivisibles ( n ) :
    Hash = [ False for i in range ( 10 ) ]
    m = n
    while ( m ) :
        Hash [ m % 10 ] = True
        m = m // 10
    ans = 0
    for i in range ( 1 , int ( math . sqrt ( n ) ) + 1 ) :
        if ( n % i == 0 ) :
            if ( isDigitPresent ( i , Hash ) ) :
                ans += 1
            if ( n // i != i ) :
                if ( isDigitPresent ( n // i , Hash ) ) :
                    ans += 1
    return ans
n = 15
print ( countDivisibles ( n ) )

Accumulator variables: ans
Iterator variables: i