Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLizette Garcia
Courses Plus Student 2,667 PointsFrom the instructions, it is not clear to me what should happen if maxFactor < 0.
Can someone please let me know what I am missing? I am getting this error: BuildMultiplicationTable returned null Thanks!
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[][] BuildMultiplicationTable(int maxFactor)
{
if (maxFactor > 0) {
int [][] table = new int[maxFactor + 1][];
for (int row = 0; row < maxFactor; row++) {
table[row] = new int[maxFactor +1];
for (int col = 0; col < maxFactor; col++) {
table[row][col] = row * col;
System.Console.Write(table[row][col]);
}
System.Console.WriteLine();
}
return table;
} else return new int[0][];
}
}
}
1 Answer
Steven Parker
231,198 PointsYour table contents are missing a row and column.
Your loops should test for "<=
" instead of just "<
", since you want to include the maxFactor row and column. Also, your Write/WriteLine's may be confusing the checker. And you don't need to make a special case for values <= 0. It's not a bad idea, but not required by the challenge.