###### Calvin Secrest

22,681 Points# I'm confused with it's multiplication table

Return a multiplication table consisting of a 2D multidimensional array. The table should contain all of the products of integers from 0 to maxFactor. For example, if maxFactor is 3 the resulting multiplication table should contain the following: 0 0 0 0 0 1 2 3 0 2 4 6 0 3 6 9

Bummer! Your code could not be compiled. Please click on "Preview" to view the compiler errors. Restart Preview Get Help Recheck work Math.cs

```
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[,] BuildMultiplicationTable(int maxFactor)
{
for (int i = 0; i < array.Length; i++)
{
System.Console.Write("maxFactor({0}): ", i);
}
}
}
}
```

## 7 Answers

###### Philip Graf

14,533 PointsHi Calvin,

there were multiple errors in your code. First, the challenge tells you to use a jagged array(`int[][]`

), not a multidimensional(`int[,]`

) one. Also, you have to declare and return an array instead of printing the results to the Console.

Well, you can have a look at this code, which should work for the challenge:

```
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[][] BuildMultiplicationTable(int maxFactor)
{
int[][] arr = new int[maxFactor + 1][];
for (int x = 0; x <= maxFactor; x++)
{
arr[x] = new int[maxFactor + 1];
for (int y = 0; y <= maxFactor; y++)
{
arr[x][y] = x * y;
}
}
return arr;
}
}
}
```

I would recommend you to study the structure instead of just copy&paste. If you get stuck, you can review the videos, and of course feel free to ask me!

Best Regards, Philip

###### Terry McDuffie

12,786 Points@CalvinSecrest did you ever complete this challenge?

###### Calvin Secrest

22,681 PointsI did thanks for checking on my issued

###### Terry McDuffie

12,786 PointsI'm having trouble how did you get it to compile Calvin Secrest

###### Justin Blankinship

5,084 Points```
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[,] BuildMultiplicationTable(int maxFactor)
{
int[,] arr = new int[maxFactor + 1, maxFactor +1];
for (int x = 0; x <= maxFactor; x++){
for (int y = 0; y <= maxFactor; y++)
{
arr[x, y] = x * y;
}
}
return arr;
}
}
}
```

###### Andrei Li

33,372 PointsI am just happy! Here is my solution:

```
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[][] BuildMultiplicationTable(int maxFactor)
{
int[][] result = new int[maxFactor+1][];
for(int i=0; i <= maxFactor;i++)
{
result[i] = new int[maxFactor+1];
for(int j = 0; j <= maxFactor; j++)
{
result[i][j] = i*j;
}
}
return result;
}
}
}
```

###### Ricardo Ferreira

9,693 PointsQuestion, is the maxFactor + 1 added inside the [] because we count from zero?

###### Daniel Yates

7,319 PointsCorrect

###### HIDAYATULLAH ARGHANDABI

20,990 PointsDear Cavin

```
using System.Collections.Generic;
using System;
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static List <int> GetPowersOf2 (int UpperLimit)
{
var PowersOf2List = new List <int> ();
for (int index = 0; index < UpperLimit + 1; index++)
{
PowersOf2List.Add ( (int) Math.Pow (2, index) );
}
return PowersOf2List;
}
}
}
```

## Calvin Secrest

22,681 Points## Calvin Secrest

22,681 PointsThanks for you assistance