1. Member
Join Date
Jan 2011
Posts
15
Rep Power
0

## fibbonacci series- please its emergency

hi huys. i have a question why in this code firstNumber = secondNumber and secondNumber = number[i]; ??????????

PHP 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);```
Last edited by zoala001; 01-14-2011 at 12:10 PM.

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

3. Member
Join Date
Jan 2011
Posts
15
Rep Power
0
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.

4. 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!

5. Member
Join Date
Oct 2008
Location
UK
Posts
65
Rep Power
0
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!
Last edited by Paul Richards; 01-14-2011 at 02:00 PM.

6. Member
Join Date
Oct 2008
Location
UK
Posts
65
Rep Power
0
Java 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);
}
}```

#### Posting Permissions

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