Skip to content

Commit 8691b3e

Browse files
committed
numerators
1 parent 01b2de5 commit 8691b3e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

haskell/maths/src/numerators.hs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Data.Ratio
2+
3+
toNums :: Int -> [Int] -> [Int]
4+
toNums a = fmap (numerator . (% a))
5+
6+
toNumList :: Int -> [Int]
7+
toNumList a = toNums a [1..(a-1)]
8+
9+
-- A112544
10+
bigList :: [Int]
11+
bigList = concat $ toNumList <$> [2..20]
12+
13+
triangleList :: String
14+
triangleList = unlines $ fmap show $ toNumList <$> [2..40]
15+
16+
main :: IO ()
17+
main = putStrLn triangleList
18+
19+
-- Mine
20+
sumList :: [Int]
21+
sumList = sum . toNumList <$> [2..200]

0 commit comments

Comments
 (0)