Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: fibonacci series in reverse order

  1. #1
    Junior Member r2dak's Avatar
    Join Date
    Jul 2013
    Location
    Los Santos
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default fibonacci series in reverse order

    how can we print Fibonacci series in reverse order like

    55 34 21 13 8 5 3 2 1 1 0
    using for loop

    im just not able to figure out how to do it, please suggest me some logic to do it,
    thanks


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: fibonacci series in reverse order

    How would you do it on paper, without a computer?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member r2dak's Avatar
    Join Date
    Jul 2013
    Location
    Los Santos
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: fibonacci series in reverse order

    by the sum of the previous two numbers

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: fibonacci series in reverse order

    Pretend you have a really dumb friend who doesn't really understand how Fibonacci works. Write out specific instructions (full sentences, not code) on a piece of paper that your friend could follow to accomplish your goal. Remember how dumb your friend is, so make sure the instructions are as short and simple as possible. If one of the instructions can be broken down into multiple steps, do it.

    When you have those instructions written out, you'll have yourself an algorithm that you can start thinking about converting to code.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member r2dak's Avatar
    Join Date
    Jul 2013
    Location
    Los Santos
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: fibonacci series in reverse order

    ammm thats the problem even i not able to understand how can i print Fibonacci BACKWRADS
    i can write a program to print Fibonacci series to Nth term no problem there
    but printing it backwards is really confusing for me
    lets say we have to start from 55 then next will be 34
    so to print 34 we have to subtract 21 from 55, and that's the problem how can we find out what value do we have to subtract from upperbound, when the upperbound is entered by the user

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: fibonacci series in reverse order

    Say I give you a task: starting at 55, write down the Fibonacci sequence in reverse, on a piece of paper.

    How would you accomplish this task? Hint: I didn't say you can't use other pieces of paper to write whatever you want on them.

    Alternatively, you might look into something called Binet's formula.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Junior Member r2dak's Avatar
    Join Date
    Jul 2013
    Location
    Los Santos
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: fibonacci series in reverse order

    hi thx, i got it working like this , but in this case the user have to enter last two numbers instead of only last number

     
     class fibo_r {
     
        public static void main(String args[])
        {
        	int a=89,b=55,c,d,i;
           	  System.out.println(+a);
        	  System.out.println(+b);
        	for(i=a;i>1;i=i-c)
        	{
        	 c=a-b;
        	 System.out.println(+c);
        	 a=b;
        	 b=c;
        	} 
        }
     
    }

Similar Threads

  1. Fibonacci Series
    By 13cmwest in forum What's Wrong With My Code?
    Replies: 8
    Last Post: March 15th, 2013, 04:39 AM
  2. java code for fibonacci series?
    By javawreker in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 1st, 2012, 08:02 AM
  3. Fibonacci series
    By seanman in forum Algorithms & Recursion
    Replies: 4
    Last Post: September 11th, 2011, 12:32 PM
  4. problem to get Fibonacci series- please help.
    By zoala001 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 3rd, 2011, 01:10 AM
  5. Replies: 1
    Last Post: October 19th, 2009, 11:53 PM

Tags for this Thread