4 ms·
In java: public int nth_fibbonacci(int n) { if (n == 0 || n == 1) return 1; return nth_fibbonacci(n-1) + nth_fibbonacci(n-2); } //Would you accept that as a
by maeon3 16y ago
In java:
public int nth_fibbonacci(int n)
{
if (n == 0 || n == 1) return 1;
return nth_fibbonacci(n-1) + nth_fibbonacci(n-2);
}
//Would you accept that as a valid response even though it is terribly inefficient? It's what I came up with in 5 minutes.
- kenjackson 16y agoYep, that would work.