0
I’m having a problem understanding the difference between code 1 and code 2 (Fibonacci sequence). Apparently it looked the same, but the results they both print are distinct.
Code 1
qtd_elementos = int(input())
inicio = 1
somador = 0
lista_elementos = []
while (len(acumulador)) < qtd_elementos:
somador, inicio = inicio, inicio + somador
lista_elementos.append(somador)
print(acumulador)
Code 2
qtd_elementos = int(input())
inicio = 1
somador = 0
lista_elementos = []
while (len(acumulador)) < qtd_elementos:
somador = inicio
inicio += somador
lista_elementos.append(somador)
print(acumulador)
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site
– Maniero