Question d’entretien chez Millennium

fibonacci and write the recursive function

Réponses aux questions d'entretien

Utilisateur anonyme

6 févr. 2020

Your solution is incorrect, if your value of n is too high (lets say greater than 10,000) it could cause a stack overflow due to the replicated stack frames. What you want to do is provide an iterative rather than recursive solution. For example: def fibonacci(n): x = 0 ,1 for i in range(n): a,b = b,a+b return a

9

Utilisateur anonyme

6 févr. 2020

Sorry, it should be def fibonacci(n): a,b = 0,1 for i in range(n): a,b = b,a+b return a

2