DevJourney · code I wrote while learning

nxn Square Pattern inspired by Pascal's Triangle

2 items

README.md

nxn Square Pattern inspired by Pascal's Triangle

Single File Programming Question Problem Statement Tanvi is experimenting with numerical patterns inspired by Pascal's Triangle. She wants to create a square pattern of size n × n, where each row contains powers of 2 arranged in a Pascal-like format. The first element in each row should be 1, and every subsequent value in that row should be the sum of the left and top elements (if available). She designs a program using the class PowerPascalPattern with the method generatePattern() to construct and display the matrix. Input format : The first line of input contains an integer n, representing the number of rows. Output format : The output prints n lines, each containing n space-separated integers. Refer to the sample output for formatting specifications. Code constraints : The given testcases fall under the following constraints: 1 ≤ n ≤ 20 Sample test cases : Input 1 : 2 Output 1 : 1 1 1 2 Input 2 : 3 Output 2 : 1 1 1 1 2 3 1 3 6