79307887

Date: 2024-12-25 15:44:37
Score: 0.5
Natty:
Report link

What's wrong in your code:

  1. Incorrect reset Condition: The condition (column<row) does not ensure proper reset logic for column.

You can update your logic so that you can get expected output.

static void printPascal(int row, int column, int rowLimit) {
    for (; row < rowLimit; ) {
        System.out.println("(" + row + ", " + column + ")");
        if (column < row) {
            column++; // Move to the next column in the current row
        } else {
            column = 0; // Reset column for the next row
            row++;      // Move to the next row
        }
    }
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): What's
  • Low reputation (1):
Posted by: Suraj Kumar