How can I introduce the fibonacci series in an "N" matrix by "N" example:
1 1 2 3
5 . . .
My result is not as expected, it does not show the series in the matrix.
This is my code:
int i, j, n,aux;
int a = 0;
int b = 1;
n = Convert.ToInt32(Console.ReadLine());
int[,] matriz1 = new int[n, n];
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
if (i == 0)
{
matriz1[i, j] = j + 1;
}
else
{
for (int x = 0; x < n; x++)
{
aux = a;
a = b;
b = aux + a;
Console.Write(" "+a);
}
}
}
}
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
Console.Write(matriz1[i, j] + "\t");
}
Console.WriteLine(a);
}
Console.Read();
The result that appears on the screen is: 1 1 2 3 5 8 ........ 0 0 0 0 0 0