Question d’entretien chez Morgan Stanley

How would you code a non-recursive Fibonacci?

Réponse à la question d'entretien

Utilisateur anonyme

1 mars 2024

They made me type it: public int f(int n) { int tmp; int a = 3; int b = 1; for (int i = 0; i < n; i++) { tmp = a; a = 3 * a - b; b = tmp; } return b; }