Ans:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Logicals
{
class FibonassiSeries
{
static void Main(string[] args)
{
Console.WriteLine("Enter Number Only..");
int num = int.Parse(Console.ReadLine());
int temp,a=0,b=1;
int[] arr = new int[10];
arr[0] = 0;
arr[1] = 1;
for (int i = 2; i <= num-1; i++)
{
temp = a + b;
a = b;
b = temp;
arr[i] = temp;
}
for (int j = 0; j <= num - 1; j++)
{
Console.WriteLine(arr[j]);
}
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Logicals
{
class FibonassiSeries
{
static void Main(string[] args)
{
Console.WriteLine("Enter Number Only..");
int num = int.Parse(Console.ReadLine());
int temp,a=0,b=1;
int[] arr = new int[10];
arr[0] = 0;
arr[1] = 1;
for (int i = 2; i <= num-1; i++)
{
temp = a + b;
a = b;
b = temp;
arr[i] = temp;
}
for (int j = 0; j <= num - 1; j++)
{
Console.WriteLine(arr[j]);
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment