Computer Science, asked by shubhamdasmohapatra0, 8 months ago

Print the following pattern for the given N number of rows.
Pattern for N = 4
1
11
121
1221

Answers

Answered by sankhalaishant
0

Answer:

Explanation:

# Pattern 1-121-12321 pyramid pattern

# Reading number of rows

row = int(input('Enter how many lines? '))

# Generating pattern

for i in range(1,row+1):

   

   # for space

   for j in range(1, row+1-i):

       print(' ', end='')

   

   # for increasing pattern

   for j in range(1,i+1):

       print(j, end='')

   

   # for decreasing pattern

   for j in range(i-1,0,-1):

       print(j, end='')

   

   # Moving to next line

   print()

Answered by balajiyempuluru82
0

Answer:

public class Main {

public static void main(String[] args) {

Scanner s = new Scanner(System.in);

int n = s.nextInt();

int i = 1;

while(i<=n) {

int j = 1;

int odd = 1;

while(j <= n) {

System.out.print(odd);

odd = odd+2;

j++;

}

System.out.println();

i++;

}

}

}

Similar questions