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))
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))
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