zlacker

[parent] [thread] 5 comments
1. a-niko+(OP)[view] [source] 2019-11-11 01:04:47

    def digitlength(n):
        digits = 1
        while (n > 9):
            digits += 1
            n /= 10
        return digits
Also may want to set n = abs(n) in the beginning, in case n is negative.
replies(1): >>gnuvin+5
2. gnuvin+5[view] [source] 2019-11-11 01:06:25
>>a-niko+(OP)
The problem statement said that the input would be natural numbers.
replies(1): >>lifthr+M6
◧◩
3. lifthr+M6[view] [source] [discussion] 2019-11-11 02:54:32
>>gnuvin+5
Wait, do natural numbers include zero? evil grin
replies(2): >>talake+Me >>chopin+JH
◧◩◪
4. talake+Me[view] [source] [discussion] 2019-11-11 04:59:09
>>lifthr+M6
No support for that in Sloane's. https://oeis.org/A000027
◧◩◪
5. chopin+JH[view] [source] [discussion] 2019-11-11 11:59:07
>>lifthr+M6
I looked up wikipedia which says there's no conclusive definition.
replies(1): >>lifthr+pJ
◧◩◪◨
6. lifthr+pJ[view] [source] [discussion] 2019-11-11 12:14:16
>>chopin+JH
The joke is that, if you don't need to check if the input is negative because it is not a natural number, you can also choose a definition of the natural number without zero to avoid special casing it at all.
[go to top]