Como calcular series em Python? Criei um algoritmo mas não estou conseguindo chegar ao objetivo final.
Ex:
S1 = x + (x-1) + (x – 2) + ... + (x – n)
S2 = 1 𝑥 + 1 𝑥+1 + 1 𝑥+2 + … 1 𝑛
Entrei com um número inicial e outro final, mas o resultado esta dando erro. Meu código:
while True:
try:
value1 = int(input("Digite o número inicial: "))
value2 = int(input("Digite o numero final: "))
for i in range(value1,value2):
num1 = value1 +(value1-1)+(value1-2)+(value1 - value2)
i += 1
print("Valor é: ",num1)
break
break
except ValueError:
print("Obs: Somente números inteiros! Tente novamente...\n")