Computer Science, asked by rohan786singha, 1 year ago

Can anyone tell how to print this pattern using python
1
1 2 1
1 3 3 1
1 4 3 4 1

Answers

Answered by fiercespartan
3

Hey! I recently worked on this problem.

We will notice that 1 is 1*1

121 is 11*11

12321 is 111*111

1234321 is 1111*1111

To get 1, we take the remainder of 10/9

To get 11, we take remainder of 10^2/9

To get 111, we take the remainder of 10^3/9 and so on

Hence, to make this possible, we first take the input.

The code:

for i in range(1,int(input()):

      print( 10**i//9)**2

Hope it helps! :)

Similar questions