none
fibonacci series c#

    Question

  • i need code for fibonacci series of numbers... but it should calculate for only five step... which means the output should be

    0 1 1 2 3  

    tats it...

    pls help me...

    Saturday, February 12, 2011 12:23 PM

Answers

  • int oldn=0;

    int newno=1;

    int fno;

    int j=0;

    for(; ;)

    {fno=oldn+newno;

    newno=fno;

    oldn=newno;

    j++;

    if(j<4)

    {

    break;

    }

    Console.writeline(oldn,newno,fno);

    }

     

    easiest method made for you by me.

    Saturday, February 12, 2011 12:43 PM
  • Hi,

    I have some problems to understand your problem. Can you please help a little more? My answer at the moment would be:

    Console.Write("0 1 1 2 3");

    which writes a list of the first 5 fibonacci numbers - as you requested.

    Sorry, at the moment I have simply the feeling that this is a question like "Please do my homework". At least I will not write complete solutions in such cases. Target of a homework is, that you learn something. So please tell me, where you have a problem?

    - Do you need information about the fibonacci series? http://en.wikipedia.org/wiki/Fibonacci_number

    - Do you need to know how to write a program? Or you miss software? http://windowsclient.net could be a good start.

    - Do you need information about methods or loops? Or maybe you want to learn about recursion?

    Just tell us, what your problem really is and we will try to help you.

    With kind regards,

    Konrad

     

    Saturday, February 12, 2011 12:43 PM
  • There is an example of Fibonacci at this link.

    http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

    Rudy   =8^D


    Mark the best replies as answers. "Fooling computers since 1971."

    http://rudedog2.spaces.live.com/default.aspx

    Saturday, February 12, 2011 3:28 PM

All replies