Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
|||
import Control.Parallel.Strategies (parMap, rdeepseq)
|
||||
import Control.DeepSeq (NFData)
|
||||
import Data.List (maximumBy)
|
||||
import Data.Function (on)
|
||||
|
||||
nums :: [Integer]
|
||||
nums =
|
||||
[ 112272537195293
|
||||
, 112582718962171
|
||||
, 112272537095293
|
||||
, 115280098190773
|
||||
, 115797840077099
|
||||
, 1099726829285419
|
||||
]
|
||||
|
||||
lowestFactor
|
||||
:: Integral a
|
||||
=> a -> a -> a
|
||||
lowestFactor s n
|
||||
| even n = 2
|
||||
| otherwise = head y
|
||||
where
|
||||
y =
|
||||
[ x
|
||||
| x <- [s .. ceiling . sqrt $ fromIntegral n] ++ [n]
|
||||
, n `rem` x == 0
|
||||
, odd x ]
|
||||
|
||||
primeFactors
|
||||
:: Integral a
|
||||
=> a -> a -> [a]
|
||||
primeFactors l n = f n l []
|
||||
where
|
||||
f n l xs =
|
||||
if n > 1
|
||||
then f (n `div` l) (lowestFactor (max l 3) (n `div` l)) (l : xs)
|
||||
else xs
|
||||
|
||||
minPrimes
|
||||
:: (Control.DeepSeq.NFData a, Integral a)
|
||||
=> [a] -> (a, [a])
|
||||
minPrimes ns =
|
||||
(\(x, y) -> (x, primeFactors y x)) $
|
||||
maximumBy (compare `on` snd) $ zip ns (parMap rdeepseq (lowestFactor 3) ns)
|
||||
|
||||
main :: IO ()
|
||||
main = print $ minPrimes nums
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
procedure main(A)
|
||||
threads := []
|
||||
L := list(*A)
|
||||
every i := 1 to *A do put(threads, thread L[i] := primedecomp(A[i]))
|
||||
every wait(!threads)
|
||||
|
||||
maxminF := L[maxminI := 1][1]
|
||||
every i := 2 to *L do if maxminF <:= L[i][1] then maxminI := i
|
||||
every writes((A[maxminI]||": ")|(!L[maxminI]||" ")|"\n")
|
||||
end
|
||||
|
||||
procedure primedecomp(n) #: return a list of factors
|
||||
every put(F := [], genfactors(n))
|
||||
return F
|
||||
end
|
||||
|
||||
link factors
|
||||
Loading…
Add table
Add a link
Reference in a new issue