C# C# Collections Arrays Jagged Arrays

olu adesina
PRO
olu adesina
Pro Student 18,895 Points

help i dont know where to start

im not really sure where to start with is question. Im guessing max factor refers to the highest number

Math.cs
namespace Treehouse.CodeChallenges
{
    public static class MathHelpers
    {
        public static int[][] BuildMultiplicationTable(int maxFactor)
        {

        }
    }
}

2 Answers

David Tomko
David Tomko
7,741 Points

Well you're going to need to start by creating an Array of arrays like

  • int [][] arr = new int[You'll need this number to be one bigger than the number being passed in][];

Then you need a for loop with another for loop nested in it

  • The first for loop will be for the row and in here you'll need to create another int array like the one above but this one is only an int array and not an array of array
  • The second for loop with be for the value of the number in the rows
  • In this loop you'll multiple the two indexes of your for loops

In the end you'll need to add all this stuff to your array of arrays and return it

olu adesina
olu adesina
Pro Student 18,895 Points

David Tomko im still a little lost when you say the number being passed in what are you referring to

Steven Parker
Steven Parker
168,613 Points

That's right, "MaxFactor" is the highest value that will be used as an index for either dimension of the array. So your task is to create an "array of arrays" to accomodate those dimensions, and initialize the values with multiplication products.