C Sharp Program to generate Fibonacci Triangle

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

C# Program to generate Fibonacci Triangle

In this program, we are getting input from the user for the limit for fibonacci triangle, and printing the fibonacci series for the given number of times (limit).

Let's see the C# example to generate fibonacci triangle.

 
  1. using System;  
  2.   public class PrintExample  
  3.    {  
  4.      public static void Main(string[] args)  
  5.       {  
  6.        int a=0,b=1,i,c,n,j;      
  7.        Console.Write("Enter the limit: ");    
  8.        n= int.Parse(Console.ReadLine());     
  9.        for(i=1; i<=n; i++)      
  10.        {      
  11.         a=0;      
  12.         b=1;      
  13.         Console.Write(b+" ");     
  14.         for(j=1; j
  15.         {      
  16.          c=a+b;      
  17.          Console.Write(c+" ");      
  18.          a=b;  
  19.          b=c;  
  20.         }      
  21.         Console.Write(" ");      
  22.        }      
  23.    }  
  24.   }  

Output:

Enter the limit: 9
1	
1	1	
1	1	2	
1	1	2	3	
1	1	2	3	5	
1	1	2	3	5	8	
1	1	2	3	5	8	13	
1	1	2	3	5	8	13	21	
1	1	2	3	5	8	13	21	34