Am Mittwoch 26 August 2009 06:29:47 schrieb George Pollard:
> You could also fudge the input:
>
> {-# LANGUAGE NoMonomorphismRestriction #-}
>
> log10 = floor . logBase 10 . (0.5+) . fromIntegral
>
> numDigits n | n < 0 = 1 + numDigits (-n)
> numDigits 0         = 1
> numDigits n         = 1 + log10 n
>
> -- checked [0..10^8], finding a counter-example is left as an exercise :P

Prelude> numDigits (10^15)
15


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to