Write a program to print the following pattern. Sample Input: 5 Sample Output:
1
2*2
3*3*3
4*4*4*4
5*5*5*5*5
5*5*5*5*5
4*4*4*4
3*3*3
2*2
1
Answers
Answered by
5
Language used: Python Programming
Program:
n=int(input())
l=[]
for i in range(1,n+1):
row=(str(i)+'*')*i #making each row as string
l.append(row[:-1]) #leaving last extra '*'
print(row[:-1])
for i in l[::-1]: #reverse the list so that we can print from the back.
print(i)
Input:
5
Output:
1
2*2
3*3*3
4*4*4*4
5*5*5*5*5
5*5*5*5*5
4*4*4*4
3*3*3
2*2
1
Learn more:
1. Write a program to print the following pattern.
https://brainly.in/question/11917943
2. Write a program to display prime fibonacci numbers from 100 to 1000 in java
https://brainly.in/question/18378925
Attachments:
Similar questions