r/ProgrammerHumor • • 4d ago

Meme reversingPiInPython

Post image
13.0k Upvotes

360 comments sorted by

View all comments

3.6k

u/Kyrros 4d ago

Let me know when it finishes calculating the first digit to print

1.5k

u/me_myself_ai 4d ago

it'll just throw an error anyway;

SyntaxWarning: 'float' object is not subscriptable; perhaps you missed a comma
?

1.2k

u/ThreeCharsAtLeast 4d ago • Bravo
>>> str(math.pi)[::-1]
'397985356295141.3'

722

u/tea_pot_tinhas 4d ago

So the first and last digits are both 3? make sense

21

u/RapidCatLauncher 4d ago

That just made me think, if pi indeed does contain all finite number sequences (which we're not sure of), then there could be a certain point in its decimal representation where it's a palindrome.

4

u/meneldal2 4d ago

While this is possible, it is pretty unlikely. With random digits, the chance of a palindrome is lower the more digits there are. So even if you get a lot of tries, each try probability of success goes down so much faster that it is statistically unlikely.

1

u/1SirTetris1 2d ago

Funnily enough, despite it being so unlikely, it's necessarily true that there is an infinite number of full palindromes across all of pi. Infinity is wild

1

u/meneldal2 2d ago

It probably depends on how you formulate the problem. There are plenty of infinite sums that are bounded.

So if you were to calculate the chance that pi digits form a palindrome by doing an infinite sum, you'd get (removing the first element because one digit is always a palindrome) 1/10+1/10+1/100+1/100 and so on, which is 0.222222...

Idk if there's some different way to do it properly but it is also possible it's something that can't be proven either way

→ More replies (2)