codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
-- Count number of digits in 100! -- I think the answer is below 192 but above 92 -- One can use sterling's formula to estimate the number of digits -- Expected output is 158 main = printDigitsInFactorialOf 100 where printDigitsInFactorialOf = putStr . show . countDigits . calculateFactorial calculateFactorial 0 = 1 calculateFactorial n = n * calculateFactorial predn where predn = pred n countDigits 0 = 0 countDigits n = 1 + countDigits nDiv10 where nDiv10 = n `div` 10
Private
[
?
]
Run code
Submit