Kio wrote:
For example:
1 __int64 fib4(__int64 n)
2 {
3 if ((n==1) || (n==2)) return 1;
4 else return (fib(n-1)+fib(n-2));
5 }
How to avoid conversion to int in line 4 ??
Hard to tell: '__int64' is not a standard type and the rules set
up for the type are thus environment specific. You should ask this
question in a forum devoted to the specific environment you are
using.
BTW, it is a pretty bad idea to compute Fibonacci numbers using a
recursive approach in C++. The compiler will not optimize the call
to reuse results computed before as is usual for functional
programming languages (or even the C++ compiler when computing the
value using template meta programming techniques). A simple
iterative approach is much faster.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence