Re: FIbonacci
Peteris Krumins wrote:
MARQUITOS51 wrote:
Hey guys this is the fibonacci series. But Im having this huge problem.
First of all I want to do the simplest code possible so then I can use
user defined functions and arrays. But this one didnt came out well.
Any suggestions!
#include <stdio.h>
unsigned fib(unsigned n) {
return n <= 2 ? 1 : fib(n - 1) + fib(n - 2);
}
int main(void) { printf("fib(17) is: %d\n", fib(17)); return 0; }
Somebody always proposes this solution, but it's a
poor one. Try it with fib(47), say, and tell us how
long it takes. Hint: You won't need a high-precision
timer.
--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxx
.
Relevant Pages
- Re: Disappointed by perl..
... arrays and list are not the same. ... I have looked back at the manuals and I didnt find anyplace where I could have been warned about that. ... (comp.lang.perl.misc) - Re: Disappointed by perl..
... arrays and list are not the same. ... I have looked back at the manuals and I didnt find anyplace where I ... (comp.lang.perl.misc) - Re: help needed @ Listener to combo-box
... I think you didnt' get what I wanted to ask ... arrays: one called "val" which is an array of string arrays that you ... holds strings and is used to set the JComboBox default values. ... (comp.lang.java.programmer) - Re: Returning an array with a Function
... remember reading about arrays cant be passed BYVAL even though I didnt ... > slip my mind). ... (microsoft.public.vb.general.discussion) |
|