On Sat, Jan 2, 2016 at 2:56 PM, Robin Koch <robin.k...@t-online.de> wrote: > > Yes, should work for n >= 1. >
The first power of 10 for which it fails in my machine is 10 ^ 17, which is not that much for modern computers. Discrete math should not meet floating points. I would post the "canonical" solution here if Peter Otten hadn't just posted it. You can use Wolfram Alpha - or Otten's solution - to see that your solution fails for inputs equal to and larger than 10^17 (there likely is a lower bound, but I won't do binary search to find it). -- Bernardo Sulzbach -- https://mail.python.org/mailman/listinfo/python-list