How do I construct a pyramid using a loop program, given a number of rows by a user's input? Such as
*
***
*****
*******
I've tried watching several videos and reading articles about the logic of this, but instructors were either not understandable or they skipped lines of reasoning.
I know every row increases by 2 stars, and I know that because every row has an odd number of stars I can define the number of stars in a row as 2n+1 where n is an integer. I noticed a 2 row triangle has a base of 3 stars, a 3 row triangle has a base of 5 stars, and so on. So for an nth row, the triangles base is n+(n-1), which is 2n-1. For example, r_5: base = 9 stars. The next thing I know my program needs to consider is spacing. I noticed, from the base, spacing increases by 2 every row until we have n-1 spaces on the first half and another n-1 spaces on the second half, in other words, spacing increases from the base until it is greater than or equal to 2b-2.
I think all that covers the gist a java program would need to know: the number of stars per row, the size of the base, and spacing. But how do I translate all this in terms of a for while loop?