Question: Write a program that takes as input a positive integer n and generates the following shape. 1 1 3 1 3 5 1 3 5

Write a program that takes as input a positive integer n and generates the following shape.

1

1 3

1 3 5

1 3 5 7

.

.

.

1 3 5 7 9 ... 2n-1

That is, row one contains the first positive odd integer 1, row two contains the first two odd integers 1 and 3, and in general, row i contains the first i odd integers 1, 3, , 2i 1, separated by spaces. If n = 6, the output should look like (note that every two consecutive rows are separated by an empty row):

1

1 3

1 3 5

1 3 5 7

1 3 5 7 9

1 3 5 7 9 11

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!