Friday, 1 September 2017

c# Program tutorial to generate Fibonacci series up to N Numbers

create a simple c# program to generate Fibonacci series up to N Numbers

Program

using System;
class Program
    {
        static void Main(string[] args)
        {
               int a = 0, b = 1, c = 1, n;
               Console.WriteLine("Number:");            
n = Convert.ToInt32(Console.ReadLine());
               Console.WriteLine(a);            
Console.WriteLine(b);
               while((a+b)<=n)
               {
                 c = a + b;
                Console.WriteLine(c);
                 a = b;
                 b=c;
            }
        }

Output


0 comments:

Post a Comment