Reputation: 645
What is the simplest method to print star pyramid with minimal code? It shouldn't use more than one looping statement. I've produced pyramids with nested loop but I need more leaner code.
Upvotes: 0
Views: 1114
Reputation: 7
var b = 8;
int a =1;
for(int i=b;i>0;i--){
print(' '*i + '* '*a);
a=a+1;
}
Upvotes: -2
Reputation: 161
const int row = 5;
for(int i = 0;i<row;i++){
stdout.writeln(" "*(row-i)+"* "*i);
}
Upvotes: 1