0
Print this - I am stuck at this problem.. help I want a logical program for this.
if we take n=3 then output:123 654 789 similarly- n=5 then output: 12345 109876 1112131415
5 odpowiedzi
+ 5
https://code.sololearn.com/crhQTOdJ7jv8/?ref=app..
Check this
0
Bilbo Baggins awesome dude thanks for your answer.. its really appreciable
0
😎 "Awesome" Lover ❤️ nice try dude.. but you forgot 789 at the last.. btw thanks
0
Change the patternVal to any number it will return the pattern dynamically
const PrintPattern = () => {
let k='',m=1;
for(let i = 1;i<=PatternVal;i++){
let l=i%2 == 0 ? i*PatternVal : i*PatternVal;
m=i%2!==0&&i>1?(i-1)*PatternVal+1:m;
for(let j = 1;j<=PatternVal;j++){
if(i%2!==0){
k=k+m+' ';
m++;
}else{
k=k+l+' ';
l--;
}
}
k = k + '\n';
}
return k;
}