Anonymous user
First power of 2 that has leading decimal digits of 12: Difference between revisions
First power of 2 that has leading decimal digits of 12 (view source)
Revision as of 19:08, 21 May 2020
, 3 years ago→{{header|Haskell}}
Line 274:
{{trans|Python}}
<lang haskell>import Control.Monad (guard)
import Text.Printf (printf)
p ::
p l n = calc !! pred n
where
digitCount = floor $ logBase 10 (fromIntegral l :: Float)
log10pwr = logBase 10 2
calc = do
raised <- [-1 ..]
|