+ 2
Could I have done it better?
I just tried my hand at a Fibonacci sequence generator and, I want to know if there is a better way to get the same results. https://code.sololearn.com/cOzEEH1C6m43 code: i,F1,F2,Fn = 0,0,0,0 fib_seq = {} while i <= 15: Fn = F1 + F2 fib_seq[i] = Fn i += 1 if F1 == 0: F1 += 1 else: F1,F2 = F2,Fn print(list(fib_seq.values())) output: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]
4 Antworten
+ 3
https://code.sololearn.com/c4baNTx6kKxC/?ref=app here how you could do it different.
+ 2
Here you can do like these too
https://code.sololearn.com/chnunsPVmqtY/?ref=app
https://code.sololearn.com/cP4T5IQfJhD2/?ref=app
+ 2
You can make alternations
My try in python:
https://code.sololearn.com/cRdvpVrWwP57/?ref=app
+ 1
I've improved it.
https://code.sololearn.com/ctoH54pCYvSl