Printing the following pattern-
Example Input: 5
Output:
15
14.10
13.09.06
12.08.05.03
11.07.04.02.01
This is the code that I wrote:
def solve(n):
# write your code here
a = (n * (2 + (n - 1))) // 2
for i in range(n,0,-1):
for j in range(n,i-1,-1):
print(str(a).zfill(2),end = ' ')
a -= 1
print()
Output:
15
14 14
13 13 13
12 12 12 12
11 11 11 11 11
I don't know where I am going wrong. It would be great if someone could help me with this!