Data update
This commit is contained in:
parent
9817d9b99b
commit
07c7092a52
140 changed files with 2712 additions and 241 deletions
29
Task/Tau-function/Haskell/tau-function-2.hs
Normal file
29
Task/Tau-function/Haskell/tau-function-2.hs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import Data.Numbers.Primes
|
||||
import Data.List (group, intercalate, transpose)
|
||||
import Data.List.Split (chunksOf)
|
||||
import Text.Printf
|
||||
|
||||
----------------------- OEISA000005 ----------------------
|
||||
|
||||
oeisA000005 :: [Int]
|
||||
oeisA000005 = tau <$> [1..]
|
||||
|
||||
tau :: Integer -> Int
|
||||
tau = product . fmap (succ . length) . group . primeFactors
|
||||
|
||||
|
||||
--------------------------- TEST -------------------------
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn $
|
||||
(table " " . chunksOf 10 . fmap show . take 100)
|
||||
oeisA000005
|
||||
|
||||
|
||||
------------------------ FORMATTING ----------------------
|
||||
|
||||
table :: String -> [[String]] -> String
|
||||
table gap rows =
|
||||
let ws = maximum . fmap length <$> transpose rows
|
||||
pw = printf . flip intercalate ["%", "s"] . show
|
||||
in unlines $ intercalate gap . zipWith pw ws <$> rows
|
||||
Loading…
Add table
Add a link
Reference in a new issue