Challenge: find the first value where two functions differ

Ian Kelly ian.g.kelly at gmail.com
Fri Aug 4 13:59:13 EDT 2017


On Fri, Aug 4, 2017 at 11:50 AM, Chris Angelico <rosuav at gmail.com> wrote:
> My logic was that floating point rounding is easiest to notice when
> you're working with a number that's very close to something, and since
> we're working with square roots, "something" should be a perfect
> square. The integer square root of n**2 is n, the ISR of n**2+1 is
> also n, and the ISR of n**2-1 should be n-1. I actually wanted to
> start at 2**53, but being an odd power, that doesn't have an integer
> square root, so I started at 2**52, which has an ISR of 2**26.

A slight irony here is that it actually would have taken your script a
*very* long time to get to 2**53 having started at 2**52, even only
iterating over the perfect squares.



More information about the Python-list mailing list