I have an issuing multiplying two one dimension arrays together. Each array is an unsigned long that is storing values of factorials. The last row is completely off. My code is below also with a screenshot of the output.
void setup() {
//----------------------------- start serial monitor
Serial.begin(9600);
Serial.println("Factorial Table");
//----------------------------- declare variables
unsigned long fact = 1;
unsigned long r[5];
unsigned long c[5];
unsigned long product[6][6];
//----------------------------- load facotirals into array(s)
for (unsigned long d = 1; d <= 5; d++)
{
fact = fact * d;
r[d] = fact;
c[d] = fact;
}
//----------------------------- multiply factorials
// and load into new array
for (int row = 1; row <= 5; row++)
{
for (int col = 1; col <= 5; col++)
{
product[row][col] = r[row] * c[col];
}
}
//----------------------------- print factorials
for (int prow = 1; prow <= 5; prow++)
{
for (int pcol = 1; pcol <= 5; pcol++)
{
Serial.print(product[prow][pcol]);
Serial.print(" ");
}
Serial.println(" ");
}
}
