A question on modification of a list via a function invocation

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Sep 8 03:48:27 EDT 2017


Steve D'Aprano wrote:
> A harder question is, what if you take a random number from the Integers? How
> many digits will it have in (say) base 10? I don't have a good answer to that.
> I think it may be ill-defined.

I think the answer is that on average it has infinitely many
digits -- despite every actual integer only having finitely
many digits!

We can prove this by contradiction. Suppose the answer were
some finite number N. There are only finitely many integers
with N or fewer digits, but there are infinitely many with
more than N digits, so including them in the average must
make it bigger than N. So N cannot be finite.

-- 
Greg



More information about the Python-list mailing list