# Why `divmod(float('inf'), 1) == (float('nan'), float('nan'))`

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Sep 18 05:29:52 CEST 2014

```Chris Angelico wrote:

> On Thu, Sep 18, 2014 at 4:03 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
>> On Wed, Sep 17, 2014 at 9:10 AM, Chris Angelico <rosuav at gmail.com> wrote:
>>> And while it's
>>> conceivable to define that infinity divided by anything is infinity,
>>> and infinity modulo anything is zero, that raises serious issues of
>>> primality and such; I'm not sure that that would really help anything.
>>
>> I missed that this point was already discussed. Can you elaborate on
>> the "serious issues of primality and such"? Since infinity is not a
>> natural number, its primality is undefined, so I don't see the issue
>> here.
>
> It's not something I've personally worked with, so I'm trying to
> dredge stuff up from my brain, but I think there's something along the
> lines of "stuff shouldn't be a multiple of everything" and the Prime
> Number Theorem. But that may just be a case where float != real.

I don't think that the Prime Number Theorem has anything to say about
transfinite numbers (infinities). It says that for sufficiently large
values of n, the number of primes below n asymptotically approaches the the
integral of 1/ln(x) between 2 and n:

π(n) ~ Li(n)

(Note that in this case, π is not pi = 3.1414... but is the "prime counting
function", thus proving that no matter how famous or well-known a
particular mathematical symbol is, somebody will insist on using it for
something else.)

Perhaps you are thinking of the Fundamental Theorem of Arithmetic, which
states that every positive integer except 1 can be uniquely factorized into
a product of one or more primes?

http://mathworld.wolfram.com/FundamentalTheoremofArithmetic.html

But that doesn't apply to infinity, which isn't an integer.

--
Steven

```