programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Fibonacci numbers are 0 and 1.

sudhakar venkat
Greenhorn
Posts: 8
How to slove this problem.

First 2 Fibonacci numbers are 0 and 1.

Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Hi,

i can not understand this!

thanks & regards,
seetharaman

Christophe Verré
Sheriff
Posts: 14691
16
How to slove this problem.

What is your problem ? If you know what a Fibonacci number is, you should not have any problem Where are you stuck ?

Amit Ghorpade
Bartender
Posts: 2856
10
And yes dont expect us to do your homework, DoYourOwnHomework

Hope this helps

abhishek pendkay
Ranch Hand
Posts: 184
seetharam
i can not understand this!

What is it that you cannot understand

Mintoo kumar
Ranch Hand
Posts: 61
if you want to know the code.

code:
________________________________________________________________

[solution deleted]
_________________________________________________________________

Might above code will be helpful and also change accordingly above is the basic exampel.

______________________________________________________________________
Mintoo
SCJP 1.4
_______________________________________________________________________
[ April 30, 2008: Message edited by: fred rosenberger ]

Campbell Ritchie
Marshal
Posts: 56570
172
Originally posted by mintoo kumar:
if you want to know the code.
Please don't simply post answers like that, otherwise nobody will learn anything.

And the first two Fibonacci numbers in the commonest sequence are 1 and 1, not 0 and 1. The 10th number in the commonest fibonacci sequence is 55. Your method prints 55 as the 9th member of its sequence.

Christophe Verré
Sheriff
Posts: 14691
16
And the first two Fibonacci numbers in the commonest sequence are 1 and 1, not 0 and 1.

Wikipedia does not agree

Mintoo kumar
Ranch Hand
Posts: 61
Dear Ritchie,

I do agree that i should not write simply the code ,actually i misunderstood the problem. But as far as my code is concernt it's fine

___________________________________________________________________________
And the first two Fibonacci numbers in the commonest sequence are 1 and 1, not 0 and 1. The 10th number in the commonest fibonacci sequence is 55. Your method prints 55 as the 9th member of its sequence.
___________________________________________________________________________

In my code i consider a=0,b=1 which is the initial number of fibnocii series. I have not mentioned it in output because i already declalred it .so if you consider this a=0,b=1 then output will be like 0,1,1,2,3.....
I believe now you will find it correct.

________________________________________________________________
Mintoo
________________________________________________________________

fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Originally posted by mintoo kumar:
I do agree that i should not write simply the code

Mintoo

JavaRanch policy is that we do not provide solutions. I guess the corolary to Do Your Own Homework would be "Don't Do Someone Else's Homework". I have removed your solution.

Campbell Ritchie
Marshal
Posts: 56570
172
Originally posted by Christophe Verre:

Wikipedia does not agree
And how often has Wikipedia got anything right?

Jim Yingst
Wanderer
Sheriff
Posts: 18671
Originally posted by Campbell Ritchie:
And how often has Wikipedia got anything right?

Pretty often. I mean, I know that wikipeida is more than capable of getting things wrong, but overall my experience is that their info is good much more often than it's bad. You seem to be massively overstating their problems.

In this case, it seems obvious that the Fibonacci sequence F(1, 1) is a subsequence of F(0, 1). So are F(1, 2), F(2, 3), F(2, 5) etc. And there's no other Fibonacci sequence that F(0, 1) is contained within. So it seems natural to start the sequence as far back as possible and consider that the beginning. It's possible to define things differently, but I don't really see the point. The differences are pretty trivial anyway, as long as you know which definition is being used at any given time.

Campbell Ritchie
Marshal
Posts: 56570
172
All right, then, I'll believe that the 0th member is 0 and the 1st member is 1, at least of the commonest Fibonacci sequence. That has the advantage of allowing you to say

Jim Yingst
Wanderer
Sheriff
Posts: 18671
Um, OK. The Wikipedia article also uses 0 and 1 as the indices for values 0 and 1. It's arguable whether those should be called "first" and "second" or "zeroth" and "first". But we have that same ambiguity talking about Java arrays.

[Jim]: And there's no other Fibonacci sequence that F(0, 1) is contained within.

This is an error on my part. The main Fibonacci sequence can be extended as far back as you like. E.g.

F(13, -8) = 13, -8, 5, -3, 2, -1, 1, 0, 1, 1, 2, 3, 5, 8, 13...

which contains F(0, 1) within it, starting from position 7 (the eighth element) . Note that the magnitudes of the earlier values mirror the later values, with alternating sign. It still seems to make some sense to me to choose 0 as the main reference point, due to symmetry. But it isn't really the earliest point possible; there is no earliest point possible.

 It is sorta covered in the JavaRanch Style Guide.