 <p>Re: Ahmad's code - a simpler approach with no recursion or pointers, fairly naive, but requires next to no computational power for anything short of really titanic numbers (roughly 2N additions to verify the Nth fib number, which on a modern machine will take milliseconds at worst)</p> <p>// returns pos if it finds anything, 0 if it doesn't (C/C++ treats any value !=0 as true, so same end result)</p> <pre><code>int isFib (long n) { int pos = 2; long last = 1; long current = 1; long temp; while (current &lt; n) { temp = last; last = current; current = current + temp; pos++; } if (current == n) return pos; else return 0; } </code></pre>