Skip to content

Commit

Permalink
Number pattern problem solved.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamabhiCH committed Apr 1, 2024
1 parent 78af9b5 commit 027d8df
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pattern_number1.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,22 @@
1 2 3 4 5 6 7 8 9
*/

const prompt = require('prompt-sync')();

const num = parseInt(prompt("Enter the line of the pattern : "));

for(let i = 1; i < num; i++){
let arr = [];
let cnt = 1;

for(let j = 1; j < 2 * num; ++j){
if(i + j >= num + 1 && (i >= j - num + 1)){
arr.push(cnt);
cnt++;
}
else{
arr.push(' ');
}
}
console.log(arr.join(' '));
}

0 comments on commit 027d8df

Please sign in to comment.