Write a c# program to generate fibonacci triangle.
using System; namespace FibonacciTriangle { class Program { static void Main(string[] args) { int n; Console.WriteLine("Enter the number of rows: "); n = int.Parse(Console.ReadLine()); int[] fibonacci = new int[n]; fibonacci[0] = 1; fibonacci[1] = 1; for (int i = 2; i < n; i++) { fibonacci[i] = fibonacci[i - 1] + fibonacci[i - 2]; } Console.WriteLine("The Fibonacci triangle is:"); for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { Console.Write(fibonacci[j] + " "); } Console.WriteLine(); } } } }
Write a c# program to generate fibonacci triangle.
Reviewed by Bhaumik Patel
on
9:40 PM
Rating: