fibinocci series

N

nelu

If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
I found it a little too late.
And please don't top-post. Your response goes below, or interspersed
with, any quoted text, which should be trimmed to what's relevant.
Thanks. It was rude of me to top post.
 
R

Richard Heathfield

Keith Thompson said:
<OT>
Sorry to quote just the sig, but I noticed you've changed the date on
the dmr quotation (it used to be "29 July 1999"). Do I sense another
anecdote, or is it just a glitch?

Glitch. Fixed. Thanks.
 
D

Dik T. Winter

> Dave Vandervies wrote: ....
>
> I also thought that what he wanted to know was how to implement the
> formula rather than how to optimize the calculation by simplifying it.
> That was my assumption, the original problem doesn't say that.

I think RH is pretty well able to implement a much more efficient solution
than the one he gave, without help from others. There was a purpose in
his posting a suboptimal solution.
 
N

nelu

I think RH is pretty well able to implement a much more efficient solution
than the one he gave, without help from others. There was a purpose in
his posting a suboptimal solution.

I'm sure you're right, however, the post was not meant to be mean.
 
R

Richard Bos

Dik T. Winter said:
No, you get O(1) when you calculate a single fibonacci number the fastest
way: for n >= 0: round(pow((sqrt(5) + 1)/2, n) / sqrt(5))).

I do not think the OP's teacher would be happy with a mere
approximation.

Richard
 
W

William Hughes

Richard said:
I do not think the OP's teacher would be happy with a mere
approximation.

Don't ignore the round. For small enough n, (those
for which the correct answer fits exactly in the type used
to hold it) this gives exact answers. For larger n, we can use a
floating point number to hold an approximation. However, for
large enough n, the answer overflows the any floating point type.
Here we have to use arbitrary precision, and the algorithm becomes
O(log(n)).

-William Hughes
 
D

Dik T. Winter

>
> I do not think the OP's teacher would be happy with a mere
> approximation.

Indeed, but mine is not. Within the precision provided it is exact. Of
course, when you exceed precision, it will be wrong, but that will be the
same with all integer solutions. Although I would not know with my last
implementation, which is, possibly, the slowest possible implementation.
The only thing it uses is Peano's successor axiom and definitions coming out
of that. It is spectacularly exponential and took about 30 minutes to
calculate fib(32).
 
E

Emmanuel Delahaye

shan a écrit :
I am a begginer in C.can anybody give the complete code for fibinocci
series (0 1 1 2 3 5 8 ...)an input is get from user to calculate how
many numbers to be printed.I am using turbo c++.

In your dreams only. We don't supply code here. We help people to write
their own. BTW if you are that lazy, at least increase your results on
Google by using the correct spelling of 'Fibonacci'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,170
Messages
2,570,925
Members
47,468
Latest member
Fannie44U3

Latest Threads

Top