Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Fibonacci numbers are 0 and 1.

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to slove this problem.

First 2 Fibonacci numbers are 0 and 1.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

i can not understand this!

thanks & regards,
seetharaman
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ?
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And yes dont expect us to do your homework, DoYourOwnHomework



Hope this helps
 
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
seetharam

i can not understand this!


What is it that you cannot understand
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Marshal
Posts: 79632
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
________________________________________________________________
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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: 79632
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Christophe Verre:

Wikipedia does not agree

And how often has Wikipedia got anything right?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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: 79632
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic