C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Fibnocci Numbers


Posted Date: 07 Sep 2008    Resource Type: Code Snippets    Category: C# Syntax

Posted By: Raghav       Member Level: Gold
Rating:     Points: 5



Fibnocci numbers are the sequence 1,2,3,5,8,13,21,34,55,89,144 ..... etc.

This sequence is known as the Fibonacci series, and is well known in mathematics. Each number is the sum of the previous two.

The C# Code Snippet will calculate a Fibnocci Number by using recursion, i.e. the Fibnocci method calls itself when necessary.


static int Fibonacci (int x)
{
Console.WriteLine ("x = {0}", x);
if (x <= 1)
{
return 1;
}
return Fibonacci (x-1) + Fibonacci (x-2);
}

static void Main( )
{
Console.WriteLine ("Fibonacci no. = {0}", Fibonacci (5));
Console.ReadKey();
}


Hope this code snippet would be useful to all members.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Calculation of Fibnocci Number  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: operator overloading using C#
Previous Resource: indexer Demo using c#
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

Help Desk

Contact Us    Privacy Policy    Terms Of Use