22 lines
616 B
Haskell
22 lines
616 B
Haskell
-- An irrational decimal fraction is created by concatenating the positive
|
||
-- integers:
|
||
--
|
||
-- 0.123456789101112131415161718192021...
|
||
--
|
||
-- It can be seen that the 12th digit of the fractional part is 1.
|
||
--
|
||
-- If d[n] represents the nth digit of the fractional part, find the value of
|
||
-- the following expression.
|
||
--
|
||
-- d[1] × d[10] × d[100] × d[1000] × d[10000] × d[100000] × d[1000000]
|
||
|
||
import Euler
|
||
|
||
nthDigit = go 1
|
||
where
|
||
go m n = if n < m*10^m
|
||
then toDigits (n `div` m) !! (n `mod` m)
|
||
else go (m + 1) (n + 10^m)
|
||
|
||
main = print $ product $ map (nthDigit . (10^)) [0..6]
|