[Devin] > import math > > def numdigits(n): > assert (n >= 0) and ((n % 1) == 0) > if n < 10: > return 1 > return int(math.log10(n)) + 1 > > (not iterative, but it'll do :) Nope, integers in Python are unbounded, and this will deliver wrong answers for "big enough" integers. Depending on the vagaries of your platform C's log10 implementation, it may even deliver a wrong answer for small n near an exact power of 10.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4