Computer Science, asked by parvathy23, 1 year ago

Write a program in python to print the pattern
1
21
321
4321
54321

Answers

Answered by rathinasamygayathri2
7

Answer:

1

21

321

4321

54321

#include <stdio.h>

int main()

{

int i, j;

for(i=1;i<=5;i++)

{

for(j=i;j>=1;j–)

{

printf(“%d”,j);

}

printf(“\n”);

}

return 0;

}

Answered by AskewTronics
12

Below are the program in python for the above question:

Explanation:

size= int(input("Enter the size of the series")) # It takes input for the size of the series.

i=1

while(i<=size): # first loop.

   j=i

   while(j>=1): # inner loop.

       print(j, end = ' ')  # print the series.

       j=j-1

   i=i+1

   print("") # for line changes.

Output:

  • When the user inputs 1, it will prints one line of the series.
  • When the user enter 4, it will prints the 4 line of the series.

Detailed explanation:

  • The above program takes inputs and prints the series which is demanded in the question.
  • The first loop print the series up to size.
  • The inner loop will print every line of the series.

Learn More:

  • python program : https://brainly.in/question/5558161
Similar questions