How would you code a non-recursive Fibonacci?
Anonymous
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; }
Check out your Company Bowl for anonymous work chats.