Jacobsthal numbers: Difference between revisions

m
Line 1,302:
import Data.Numbers.Primes (isPrime)
import Text.Printf (printf)
 
-------------------- JACOBSTHAL NUMBERS ------------------
 
jacobsthal :: [Integer]
jacobsthal = jacobsthalish (0, 1)
 
jacobsthalish :: (Integer, Integer) -> [Integer]
jacobsthalish (x, y) = unfoldr go (x, y)
where
go (a, b) = Just (a, (b, 2 * a + b))
 
--------------------------- TEST -------------------------
main :: IO ()
Line 1,335:
)
]
 
format :: (String, Int, [Integer]) -> String
format (k, n, xs) =
Line 1,342:
" "
(chunksOf 5 $ show <$> take n xs)
 
table :: String -> [[String]] -> String
table gap rows =
9,655

edits