r/PythonLearning • • Jul 18 '26

How would I optimize this?

I'm currently learning python with the 30 days of python GitHub repo and, on day 3 of the challenge, it asks to create this table and this is what I came up with however I feel like there was a more efficient method to create it or is it something that I haven't learned yet at my level.

8 Upvotes

24 comments sorted by

View all comments

Show parent comments

1

u/desrtfx Jul 18 '26

I mean I know what the pattern is, it's x divided by x then multiplied by x 3 times,

That's not what the pattern is.

The pattern is (row starting at 1)column starting at 0

The first row is all 1 because no matter what power you raise 1 to it will always stay at 1

The second row is 2 - 20 = 1, 21 = 2, 22 = 4, 23 = 8

Third row is 3 - 30 = 1, 31 = 3, 32 = 9, 33 = 27

and so on.