zlacker

[return to "My Favorite Programming Problem to Teach: Digit Length"]
1. tzs+ng[view] [source] 2019-11-11 01:32:57
>>jstrie+(OP)

  def digitLength(n):
      dlen = 1
      high = 9
      while n > high:
          dlen += 1
          high = 10*high + 9
      return dlen
◧◩
2. Mauran+8q1[view] [source] 2019-11-11 16:05:31
>>tzs+ng
That works in Python but this idea would fail in languages with fixed with integers.
[go to top]