Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,28 @@
import Data.List.Split ( chunksOf )
isGeneralizedCurzon :: Integer -> Integer -> Bool
isGeneralizedCurzon base n = mod ( base ^ n + 1 ) ( base * n + 1 ) == 0
solution :: Integer -> [Integer]
solution base = take 50 $ filter (\i -> isGeneralizedCurzon base i ) [1..]
printChunk :: [Integer] -> String
printChunk chunk = foldl1 (++) $ map (\i -> (take ( 4 - (length $ show i) )
$ repeat ' ' ) ++ show i ++ " ") chunk
prettyPrint :: [Integer] -> [String]
prettyPrint list = map printChunk $ chunksOf 10 list
oneThousandth :: Integer -> Integer
oneThousandth base = last $ take 950 $ filter (\i -> isGeneralizedCurzon base i )
[(last $ solution base) + 1 ..]
printBlock :: Integer -> [String]
printBlock base = ["first 50 Curzon numbers using a base of " ++ show base ++ " :"]
++ (prettyPrint $ solution base) ++ ["one thousandth at base " ++ show base ++
": " ++ (show $ oneThousandth base)] ++ [take 50 $ repeat '-']
main :: IO ( )
main = do
blocks <- return $ concat $ map (\i -> printBlock i ) [2 , 4 , 6 , 8 , 10]
mapM_ putStrLn blocks