Ternary nesting -- bad idea?
This functions returns the n-th number in the fibonacci sequence. Besides crappy readability, is there any reason for not doing it this way?
Code:
long unsigned int fibby(int n, long unsigned int num1 = 0LU, long unsigned int num2 = 1LU, int count = 1);
{
return (!n || n == 1) ? 0 : ((count < n) ? fibby(n, num2, num2 + num1, count + 1) : num2);
}
I've learned that the ternary can be very optimal, but does using it this way backfire that optimization? I don't think so, but tell we what you know. Just a thought.