Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
import Data.List (elemIndex)
|
||||
|
||||
sb :: [Int]
|
||||
sb = 1 : 1 : f (tail sb) sb
|
||||
where
|
||||
f (a : aa) (b : bb) = a + b : a : f aa bb
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
print $ take 15 sb
|
||||
print
|
||||
[ (i, 1 + (\(Just i) -> i) (elemIndex i sb))
|
||||
| i <- [1 .. 10] <> [100]
|
||||
]
|
||||
print $
|
||||
all (\(a, b) -> 1 == gcd a b) $
|
||||
take 1000 $ zip sb (tail sb)
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
import Data.Function (on)
|
||||
import Data.List (nubBy, sortOn)
|
||||
import Data.Ord (comparing)
|
||||
|
||||
------------------ STERN-BROCOT SEQUENCE -----------------
|
||||
|
||||
sternBrocot :: [Int]
|
||||
sternBrocot = head <$> iterate go [1, 1]
|
||||
where
|
||||
go (a : b : xs) = (b : xs) <> [a + b, b]
|
||||
|
||||
--------------------------- TEST -------------------------
|
||||
main :: IO ()
|
||||
main = do
|
||||
print $ take 15 sternBrocot
|
||||
print $
|
||||
take 10 $
|
||||
nubBy (on (==) fst) $
|
||||
sortOn fst $
|
||||
takeWhile ((110 >=) . fst) $
|
||||
zip sternBrocot [1 ..]
|
||||
print $
|
||||
take 1 $
|
||||
dropWhile ((100 /=) . fst) $
|
||||
zip sternBrocot [1 ..]
|
||||
print $
|
||||
(all ((1 ==) . uncurry gcd) . (zip <*> tail)) $
|
||||
take 1000 sternBrocot
|
||||
Loading…
Add table
Add a link
Reference in a new issue