Problem 30. pattern2.js (*** Revise***)

 /*Question is samw like the previous pattern but the pattern is as follows


1

2
2

3
3
3
*/

let fs = require("fs");
let data = fs.readFileSync(0, 'utf-8');
let idx = 0;
data = data.split('\n');

function readLine() {
idx++;
return data[idx - 1].trim();
}
//.......................................................................................

let num = parseInt(readLine()); // 3

for (let i = 1; i <= num; i++) {

for (let j = 1; j <= i; j++) {
console.log(i);
}

console.log();

}

TERMINAL:
Nobins-MacBook-Pro:STOC_MODULE 11SEPT 2022 nobinpunyo$ node pattern2.js <input.txt 1 2 2 3 3 3 Nobins-MacBook-Pro:STOC_MODULE 11SEPT 2022 nobinpunyo$

Comments