# fibbonacci series- please its emergency

• 01-14-2011, 10:46 AM
zoala001
hi huys. i have a question why in this code firstNumber = secondNumber and secondNumber = number[i]; ??????????

Code:

``` public class Fibbbo { public static void main(String []arg){ final int Num_number = 50;       long fisrtNumber = 0;       long secondNumber = 1;       long summa = fisrtNumber + secondNumber;         long[] number = new long[Num_number ];     number[0] = 0;       number[1] = 1; System.out.print("De 50 första Fibonaccitalen: " + firstNumber + ", " + secondNumber + ", ");             for(int i= 2; i < Num_number ; i++){             number[i]=firstNumber+ secondNumber;                     firstNumber = secondNumber;                     secondNumber = number[i];                     System.out.print(number[i] + ", ");                     if (i < 12)                             sum += tal[i]; }                         System.out.println(sum);```
• 01-14-2011, 10:57 AM
Fubarable
If it's that much of an emergency, I suggest that you format your code so that it's easily readable. Your indentation is random and this makes your code very difficult to interpret, and thus less likely to get an answer.

Luck.
• 01-14-2011, 11:11 AM
zoala001
Quote:

Originally Posted by Fubarable
If it's that much of an emergency, I suggest that you format your code so that it's easily readable. Your indentation is random and this makes your code very difficult to interpret, and thus less likely to get an answer.

Luck.

its urgent cuz in 2 hours i have to explain this code to my teacher.
• 01-14-2011, 11:13 AM
Fubarable
Quote:

Originally Posted by zoala001
its urgent cuz in 2 hours i have to explain this code to my teacher.

But that's your urgency, not ours (you must not have read the link I've provided, otherwise you'd understand this). But again, if it truly is urgent to you, then the best way for you to get a fast answer is to make your question as easy to answer as possible, including your code formatting. But this is entirely up to you.

Best of luck with the project!
• 01-14-2011, 12:53 PM
Paul Richards
I am trying to make a post demonstrating how I would indent this code (By the way it doesn't compile, but thats irrelevant). However, whenever I wrap the code tags around and post, the indenting disappears. Weird.

EDIT: See my post below (#6). I was using quote tags, not code tags.. doh!

The reason why it does not compile is because the names of the variables are not consitent, e.g. fisrtNumber and firstNumber. This is very rushed coding!
• 01-14-2011, 12:58 PM
Paul Richards
Code:

```public class Fibbbo {     public static void main(String []arg) {         final int Num_number = 50;         long fisrtNumber = 0;         long secondNumber = 1;         long summa = fisrtNumber + secondNumber;         long[] number = new long[Num_number ];         number[0] = 0;         number[1] = 1;         System.out.print("De 50 första Fibonaccitalen: " + firstNumber + ", " + secondNumber + ", ");         for(int i= 2; i < Num_number ; i++){             number[i]=firstNumber+ secondNumber;             firstNumber = secondNumber;             secondNumber = number[i];             System.out.print(number[i] + ", ");             if (i < 12)                 sum += tal[i];         }         System.out.println(sum);     } }```