Printing and adding fibonacci series - c# program, DOT NET Programming

Printing and adding Fibonacci series - C# Program

Hello guys i need your advice. How can i print and add Fibonacci series in my project. Please recommend some examples.

Posted Date: 2/12/2013 12:03:54 AM | Location : United States

Hey you should implement the below code in your project.


using System;  

class Fibonacci 


  public static void Main()


   int first = 1, second = 1, third, no, count = 0;

   long sum = 2;

   // ''first'', ''second'', ''third'' are the first, second & third numbers in the fibonacci series

   // ''first'' & ''second'' are both initialised to 1

   // sum of ''first'' & ''second'' are added to the ''third'' variable

   // ''sum'' will contain the sum of all the digits in the fibonacci series. It is initialies to 2 coz sum of first 2 digits is 2

   // ''no'' is the number inputted from the console up till which the fibonacci series is displayed

   // ''count'' counts the number of digits in the fibonacci series    

  Console.Write("Enter the number uptill which you want the fibonacci numbers :


  no = int.Parse(Console.ReadLine());    

   if (no >= 45)


    // checking for values out of range.

   Console.WriteLine("Out of range values. Dont enter more than 45.");

    goto exit;


  Console.Write("Fibonacci Series : 1 1");

   // Initial 2 numbers of the fibonacci series are just ''1'' & ''1'', thus writing it directly  



   third = first + second;

    // adding ''third'' = ''first'' + ''second''  

   Console.Write(" "+third);

    // display the ''third'' digit in the series     

   first = second;

    // make ''first'' digit, the ''second'' one

   second = third;

    // make ''second'' digit, the ''third'' one  

    // we did this coz in fibonacci series, each digit is a sum of previous 2 digits  

   count = count + 1;

    // increment the counter  

   sum = sum + third;

    // add the sum in the ''sum'' variable from ''third'' variable


   while((count + 3) <= no);

   // we entered the ''no'' from the console & also the first 2 digits are not from this loop  

// thus we added +3 here to the ''count'' variable so that we get the exact specified no. of digits.

// if we didnt added 3, then the series will go beyond the specified number of digits from the console via ''no''

  Console.WriteLine("\nSum of all fibonacci digits : " +sum);

   // Display the sum





Posted by david | Posted Date: 2/12/2013 12:05:09 AM

Thanks dear, I have been looking for this, want to know more. Please upload some these types of examples more.

Posted by Aliena | Posted Date: 2/12/2013 12:05:55 AM

Related Discussions:- Printing and adding fibonacci series - c# program, Assignment Help, Ask Question on Printing and adding fibonacci series - c# program, Get Answer, Expert's Help, Printing and adding fibonacci series - c# program Discussions

Write discussion on Printing and adding fibonacci series - c# program
Your posts are moderated
Related Questions
Jquery and MVC 4.5 Training Session I am looking who have industry experience working on Microsoft Technology ( MVC 4.5 ) and Jquery, who will take live online session and provi

Develop a Rummikub Game Project Description: I require a game(Rummikub) multiplayer with source codes. I have done to much but i need to help me in Algorithm who can check

Need code for Windows 8 and Windows Phone 8 that will http post images to a php file on web server. Project Description: I am working on two projects on both Windows 8/RT and

What is CTS and CLS? => CLS stands for common language specification where as CTS stands for common type system. => CLS : cls is a standard for .net . cls is small set of sp

What is DMAIC and DMADV? The Six Sigma has two key methodologies viz. DMAIC and DMADV. The DMAIC is used to improve an existing business process. While DMADV is used to create

I need Online Real Commission Management system Project Description: Real Estate -- Store and retrieve Purchase plot customers, Employee to refer the customers get commiss

Determining salvage value of an item - C# Program I am a learner of C# language and i am struggling with the programming functions in c#. Can you have any code examples for th

A Super-hero SharePoint developer with great design skills Project Description: US: Our start-up company prepares a very innovative and cool SharePoint related product with c

I want to develop SMS application with auto reply based on the content of the message using gsm modem. eg.Student results checking using cell phone via sms. How do i do this?

What is Thread.Sleep() The Thread's execution can be paused by calling Thread.Sleep method. This Thread.Sleep() method takes an integer value which  determines how long the thr