And a similarly formed algorithm for determining if a given number is a Fibonacci number:
Here's the same solution in Ruby:
Those are all iterative solutions. I think recursive solutions are also lovely!
Except that my solution is, if anything, a line or two longer than the iterative one. So this wouldn't be even a conceptually better or neater solution and since it takes more memory, it'll remain just an exercise.