Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Tail Recursion

Name: Anonymous 2011-10-19 21:09

How do i make this function tail recursive in java


public int fib(int n)
{
  return( n <= 1 ? n : fib(n-1) + fib(n-2) );
}

Name: Anonymous 2011-10-20 13:09

>>18,20,22-23
The code in >>11 is GNU-C.

>>19
This is nonsensical, if you are using a pure ANSI-C compiler to compile GNU-C you're most likely going to get errors. It's not compiler dependent cruft though, it's just a different language. Doing that is like trying to compile ocaml code with a Fortran compiler and then complaining that everything is a compiler specific extension. Compiling C++ code with an ANSI-C compiler usually won't work either, because they're different languages, I hope you've had enough examples to realize your mistake.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List