Skip to content
DevMeme
3565 of 7590
AI ML Post #3902 · source on Telegram

Copilot Finds Pi's Last Digit

Description

A Discord-style screenshot shows user "ooliver" posting a link followed by "ah" and an embedded code editor image. The code line reads `def last_digit_of_pi():` and a gray autocomplete suggestion below it returns `int(str(math.pi)[-1])`, implying GitHub Copilot generated the implementation. The joke is that pi has no final decimal digit, while Python's `math.pi` is only a finite floating-point approximation whose string representation has an arbitrary last character. It captures both AI coding-assistant confidence and a classic numerical-computing trap.

Comments

48
Anonymous ★ Top Pick Copilot solved the last digit of pi by quietly redefining infinity as however many decimals CPython felt like printing.
  1. Anonymous ★ Top Pick

    Copilot solved the last digit of pi by quietly redefining infinity as however many decimals CPython felt like printing.

  2. @paul_thunder 4y

    Not bad. Would not do it better myself

  3. @RiedleroD 4y

    def last_digit_of_pi(): digit_i = 2 prevdigit = 3 digit = 1 while True: digit = int(math.pi*10**digit_i)%10 if digit == 0: break digit_i+=1 prevdigit=digit return prevdigit it's more complicated, so it must be better

    1. @RiedleroD 4y

      made like 5 revisions until it worked how I wanted it to lol

      1. @Dobreposhka 4y

        btw

  4. @SamsonovAnton 4y

    Wow, so Pi is a rational number at the end of all. 🤪

    1. Deleted Account 4y

      Rational numbers can have no last digit

      1. @sylfn 4y

        depends on counting system

        1. Deleted Account 4y

          Obviously...

        2. @SamsonovAnton 4y

          For example, which numeral system can express Pi as a finite set of digits, provided that the base is a natural number?

          1. @sylfn 4y

            why should I select counting system with natural number as a base?

            1. @SamsonovAnton 4y

              Because it will make little practical sense otherwise - if you start inventing individual systems for each [irrational] number.

              1. @RiedleroD 4y

                I think we were talking about theoretical technicalities

  5. @zherud 4y

    Last digit of Pi is 0 if you have Pi numeric system.

    1. @azizhakberdiev 4y

      I saw someone telling that every number ends with 000... after infinite digits after point, like 3.1415...(infinite)....00000 Then I have read one more idea: there is "999999" (six nines) part after some. Such combinations are infinite, meaning that combinations with infinite repetitive digits also exist and 0000... one of them, like 11111... 222222.... etc

      1. @sylfn 4y

        Such combinations are infinite this is proven for "finite combinations", or am I mistaken?

        1. @azizhakberdiev 4y

          Yes, sure. 10 combinations are infinite, others finite. But it is theory, our math is not ripe enough to solve these problems

      2. @RiedleroD 4y

        1/3 is 0.33333… conversely, that means 3/3=0.99999…, making the smallest possible fraction (1-0.999…) equal to zero.

        1. @RiedleroD 4y

          shit like this is why I don't like math

        2. @azizhakberdiev 4y

          Hmm. It becomes obvious that Pi in binary system ends with 0000... because of "rollover" happened with 11111... as with 99999... Zero is zero in all systems, meaning that Pi will end exactly with 0000...

          1. @sylfn 4y

            unary counting system, what is zero

          2. @RiedleroD 4y

            assuming we have a ambiguous-size floating number (aka a binary number we'd write like in our usual decimal system), we could write pi as 11.001001000011111101…

            1. @RiedleroD 4y

              so no, it's not 0 at the end, also rollover doesn't exist in floating-point mathematics

      3. @zherud 4y

        Pi in Pi numeric system is 10 so the last digit is literally 0

        1. @sylfn 4y

          last digit can be either digit with largest power of base, or least power of base, so technically, 1 can also be last digit

          1. @zherud 4y

            Yea

  6. @azizhakberdiev 4y

    0.99999.... = 1 bin 0.1111111 = 1 ?

    1. @azizhakberdiev 4y

      1 = 1 .0000000000

    2. @RiedleroD 4y

      bin 10.11101 = 2**1 2^(-1) + 2^(-2) + 2^(-3) + 2^(-5)

      1. @RiedleroD 4y

        is that understandable or too much math in one place?

        1. @azizhakberdiev 4y

          Not so bad as alien math of infinities so far

          1. @RiedleroD 4y

            …that's just how a binary counting system would work outside of computers

            1. @RiedleroD 4y

              decimal works just the same way: 3.1415 = 3*10^0 + 1*10^(-1) + 4*10^(-2) + 1*10^(-3) 5*10^(-4)

              1. @RiedleroD 4y

                maybe this extended way of writing it makes it more clear: 10.11101 = 1*2^1 + 0*2^0 + 1*2^(-1) + 1*2^(-2) + 1*2^(-3) + 0*2^(-4) + 1*2^(-5)

      2. @azizhakberdiev 4y

        So 0.11111 is 1, bc 2^(-1) + 2^(-2) + 2^(-3) + 2^(-4)... = 0.5/(1-0.5) = 1

        1. @RiedleroD 4y

          not getting your calculation, but yes, 0.1111…b would be the same as 0.99999… in decimal, therefore equal 1

          1. @azizhakberdiev 4y

            b1/(1-q)

            1. @RiedleroD 4y

              now I get it even less

              1. @azizhakberdiev 4y

                the sum of an infinitely decreasing progression

                1. @RiedleroD 4y

                  aye

        2. @RiedleroD 4y

          so this, basically

  7. @azizhakberdiev 4y

    One more proof. After infinite digits after point there will be 0 because: lim(x->infinity) 10^(-x) = 0

    1. @azizhakberdiev 4y

      But base should be greater than 1. In that case idk what the number will become

    2. @RiedleroD 4y

      error in logic: there can't come anyting after infinite digits… because it doesn't have an end. That's the point of infinity and why math breaks around it

      1. @azizhakberdiev 4y

        Ofc it has not. But what comes after infinite zeros?

        1. @RiedleroD 4y

          nothing because nothing can come after infinity anything

  8. @sylfn 4y

    Please do not violate the rules! warning 1/1 for @baophan11 for spam/ad link. Your message will be deleted

  9. @b3350541 4y

    And somebody who's class is 650 lines long knows how to do real programing

Use J and K for navigation