C# Program To Generate Fibonacci Triangle

In this code snippet, we are receiving user input to determine the limit for generating a Fibonacci triangle. Subsequently, we are displaying the Fibonacci sequence according to the specified number of iterations (limit).

Let's explore a C# illustration demonstrating the creation of a Fibonacci triangle.

Example

Example

using System;

  public class PrintExample

   {

     public static void Main(string[] args)

      {

       int a=0,b=1,i,c,n,j;    

       Console.Write("Enter the limit: ");  

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

       for(i=1; i<=n; i++)    

       {    

        a=0;    

        b=1;    

        Console.Write(b+"\t");   

        for(j=1; j<i; j++)    

        {    

         c=a+b;    

         Console.Write(c+"\t");    

         a=b;

         b=c;

        }    

        Console.Write("\n");    

       }    

   }

  }

Output:

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

Input Required

This code uses input(). Please provide values below: