Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
18
Task/Left-factorials/Haskell/left-factorials.hs
Normal file
18
Task/Left-factorials/Haskell/left-factorials.hs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
fact :: [Integer]
|
||||
fact = scanl (*) 1 [1..]
|
||||
|
||||
leftFact :: [Integer]
|
||||
leftFact = scanl (+) 0 fact
|
||||
|
||||
main = do
|
||||
putStrLn "0 ~ 10:"
|
||||
putStrLn $ show $ map (\n -> leftFact !! n) [0..10]
|
||||
putStrLn ""
|
||||
|
||||
putStrLn "20 ~ 110 by tens:"
|
||||
putStrLn $ unlines $ map show $ map (\n -> leftFact !! n) [20,30..110]
|
||||
putStrLn ""
|
||||
|
||||
putStrLn "length of 1,000 ~ 10,000 by thousands:"
|
||||
putStrLn $ show $ map (\n -> length $ show $ leftFact !! n) [1000,2000..10000]
|
||||
putStrLn ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue