fibonacci series c#

# fibonacci series c#

• Saturday, February 12, 2011 12:23 PM

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

### All Replies

• Saturday, February 12, 2011 12:43 PM

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,

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?

With kind regards,

• Saturday, February 12, 2011 3:28 PM
Moderator

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

• Friday, June 03, 2011 5:36 AM

This is an example for printing Fibonacci numbers

http://www.programcall.com/6/interview/program-to-print-fibonacci-numbers-below-100.aspx