Results 1 to 6 of 6
  1. #1
    zoala001 is offline Member
    Join Date
    Jan 2011
    Posts
    15
    Rep Power
    0

    Question 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. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    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.

    Also, please look at this link: Flagging your question as Urgent or Emergent

    Luck.

  3. #3
    zoala001 is offline Member
    Join Date
    Jan 2011
    Posts
    15
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    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.

    Also, please look at this link: Flagging your question as Urgent or Emergent

    Luck.
    its urgent cuz in 2 hours i have to explain this code to my teacher.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by zoala001 View Post
    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. #5
    Paul Richards is offline Member
    Join Date
    Oct 2008
    Location
    UK
    Posts
    65
    Rep Power
    0

    Default

    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. #6
    Paul Richards is offline Member
    Join Date
    Oct 2008
    Location
    UK
    Posts
    65
    Rep Power
    0

    Default

    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);
        }
    }

Similar Threads

  1. problem to get Fibonacci series- please help.
    By zoala001 in forum Java Applets
    Replies: 17
    Last Post: 01-02-2011, 01:50 PM
  2. Replies: 0
    Last Post: 03-28-2010, 10:55 AM
  3. Perrin series
    By moamen in forum New To Java
    Replies: 6
    Last Post: 12-04-2009, 06:27 PM
  4. Help with summing series
    By xplsivo in forum New To Java
    Replies: 8
    Last Post: 11-23-2009, 08:37 PM
  5. How to add a second series in jfreechart
    By Manfizy in forum New To Java
    Replies: 1
    Last Post: 03-23-2009, 12:16 PM

Posting Permissions

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