# Thread: I really need help with this..

1. Member
Join Date
Jun 2013
Posts
7
Rep Power
0

## 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:
Java 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;
}
}```

2. ## 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..

Java Code:
```counter=0;
while (counter < 50)
{
current = previous2 + previous1;
previous1 = previous2;
previous2 = current;
System.out.println(current);
counter++;
}```
Last edited by Kuttappu; 06-25-2013 at 09:50 PM.

3. ## Re: I really need help with this..

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

4. ## Re: I really need help with this..

@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.

5. ## Re: I really need help with this..

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

6. ## Re: I really need help with this..

Thank you again. Now i got it..

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•