# I really need help with this..

• 06-25-2013, 08:29 AM
nu2programming
I really need help with this..
Well I have the Fibonacci Number programming up and running very well and all I need to do is print the next 50 Fibonacci numbers along with the answer that I get, by the way I'm using eclipse, and here is the code:
Code:

```import java.util.Scanner; public class FibonacciNumber {         private static Scanner console;         /**         * @param args         */         public static void main(String[] args) {                 // TODO Auto-generated method stub                                 //Variables                 int previous1;                 int previous2;                 int current = 0;                 int counter;                 int nthFibonacci;                 Object FubonacciNumber;                                 Scanner console = new Scanner(System.in);                                 //Prompt the user for input                                System.out.println("Enter the first Fibonacci number: ");                 previous1 = console.nextInt();                                 System.out.println("Enter the second Fibonacci number: ");                 previous2 = console.nextInt();                                 System.out.println("The first two numbers of the Fibonacci sequence are: "                 + previous1 + "and" + previous2);                                 System.out.println("Enter the position of the desired number in " +                 "the Fibonacci sequence: ");                 nthFibonacci = console.nextInt();                                                 if (nthFibonacci == 1)                         current = previous1;                 else if (nthFibonacci == 2)                         current = previous2;                 else                 {                         counter = 3;                                                 while (counter <= nthFibonacci)                         {                                 current = previous2 + previous1;                                 previous1 = previous2;                                 previous2 = current;                                 counter++;                         }                 }                                                 System.out.println("\nThe " + nthFibonacci + "th Fibonacci number of "                                 + "the sequence is: " + current);                         }         private static int nextInt(int counter) {                 // TODO Auto-generated method stub                 return 0;         } }```
• 06-25-2013, 10:31 AM
Kuttappu
Re: I really need help with this..
Is this what you want? - after printing nth number it should print (n+1)th number to (n+50)th number in the series.

If so try following code after line 56..

Code:

```counter=0; while (counter < 50) { current = previous2 + previous1; previous1 = previous2; previous2 = current; System.out.println(current); counter++; }```
• 06-25-2013, 02:56 PM
DarrylBurke
Re: I really need help with this..
Quote:

Originally Posted by nu2programming
I really need help with this..

Please go through the Forum Rules, particularly the third paragraph.

@Kuttappu: Please go through the http://www.java-forums.org/forum-gui...w-members.html and BB Code List - Java Programming Forum - Learn Java Programming and edit your psot accordingly.

db
• 06-25-2013, 10:57 PM
Kuttappu
Re: I really need help with this..
Quote:

@Kuttappu: Please go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your psot accordingly.
Thank you Darryl.

Actually, when i posted the code i searched how to put code in this editor, but could only find smileys, quotes, url, insert image, insert video etc.

I suggest, it will be a good idea to place a "insert code" icon also in this editor along with others.
• 06-25-2013, 10:59 PM
DarrylBurke
Re: I really need help with this..
Quote:

Originally Posted by Kuttappu
I suggest, it will be a good idea to place a "insert code" icon also in this editor along with others.

You can find that in the advanced editor.

db
• 06-25-2013, 11:02 PM
Kuttappu
Re: I really need help with this..
Thank you again. Now i got it..