loading...

re: Daily Challenge #249 - Incremental Changes VIEW POST

FULL DISCUSSION
 

In Python:

def alg(number, steps, iter_num):
    # make iteration for adding number
    for i in range(steps):
        number += iter_num

    return number

Another 'short'-cut:

# a 'short'-cut way
def alg(number, steps, iter_num):
    return number + steps * iter_num

Applying function

print(alg(100, 5, 50))    # 350
print(alg(14, 20, 4))      # 94
code of conduct - report abuse