First power of 2 that has leading decimal digits of 12: Difference between revisions

m
Line 274:
{{trans|Python}}
<lang haskell>import Control.Monad (guard)
import Text.Printf (printf)
 
p :: IntegerInt -> Int -> Integer
p l n = calc !! pred n
where
digitCount = floor $ logBase 10 (fromIntegral l :: Float)
log10pwr = logBase 10 2
calc = do
raised <- [-1 ..]
Anonymous user