Computer Science, asked by anshkatiyar4105, 3 months ago

write a program to print pattern like
1
21
321
4321
54321​

Answers

Answered by allysia
4

Language:

Python

Program:

___________________________________________

n=int(input("Enter the number of rows: "))

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

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

       a=j

       print(a,end="")

       a=j+1        

   print()

___________________________________________

Output:

Enter the number of rows: 5

1

21

321

4321

54321

Explanation:

n accepts the number of rows.

Loop 1 increases the number by 1 per loop and another nested loop controls number per row and prints them in reverse.

Similar questions