Please say anyone just for loop for this pattern
Asked
Active
Viewed 85 times
-5
-
Hello Badisa, welcome to stack overflow. Please provide a specific example on what you are trying to achieve, given it is unclear only from the picture. What is the desired output? Have you attempted some sort of code already, and do you have any additional information? – jlb_gouveia Apr 26 '21 at 15:34
-
Hello Badisa. To be able to provide an answer, please elaborate more on the question. Provide more inputs and example what you would like to achieve. The question is tagged with "gooddata" tag. Does it somehow relate to the GoodData SaaS Business Intelligence Platform? If so, could you please explain the relation? Thank you. M – Martin Burian Apr 26 '21 at 17:58
3 Answers
1
say join ' ', map qw( * # )[$_ % 2], 1 .. $_ for 1 .. 5;

choroba
- 231,213
- 25
- 204
- 289
-
-
1Perl. If you were interested in a particular language, you should have tagged the question. – choroba Apr 27 '21 at 07:21
1
Python:
for a in range(0, 5):
for b in range(0, a+1):
if (b%2==0):
print("#", end=' ')
else:
print("*", end=' ')
print()

Martin Burian
- 98
- 3
0
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
if(j%2==0)
{
System.out.print("#");
}else
{
System.out.print("*");
}
}
System.out.println("\n");
}

Badisa Naveen
- 1
- 2