Fibonacci Triangle in C Sharp

Fibonacci Triangle

In C#, we can take input from the user for the limit for a Fibonacci triangle. The Fibonacci series can then be printed for that range or limit.

Example:

using System;  
  public class Example  
   {  
     public static void Main(string[] args)  
      {  
       int x=1, y=2, i, z, num, j;      
       Console.Write("Enter the range: ");    
       num = int.Parse(Console.ReadLine());     
       for(i=1; i<=num; i++)      
       {      
        x = 0;      
        y = 1;      
        Console.Write(y + "\t");     
        for(j=1; j<i; j++)      
        {      
         z = x+y;      
         Console.Write(z + "\t");      
         x = y;  
         y = z;  
        }      
        Console.Write("\n");      
       }      
   }  
  }

Output:

Explanation:

In the above example, we are printing a Fibonacci triangle with the first two numbers as 1 and 2.

Please Share