with transformation [closed]

0
def eR(k,x):

    if k<=1:

     return 1
    else:
        return (x**k)/eR(k-1,x)*k

x=int(input("Insira o X:"))

k=int(input("Insira o número de termos:"))

print(eR(k,x))
    
asked by anonymous 28.09.2018 / 21:47

1 answer

1
def eR(k, x):
    result = 1
    for kp in range(2, k + 1):
        result = (x ** kp) / result * kp
    return result

With while:

def eR(k, x):
    kp = result = 1
    while kp < k:
        kp += 1
        result = (x ** kp) / result * kp
    return result
    
28.09.2018 / 21:54