Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/Parallel-calculations/F-Sharp/parallel-calculations.fs
Normal file
19
Task/Parallel-calculations/F-Sharp/parallel-calculations.fs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
open System
|
||||
open PrimeDecomp // Has the decompose function from the Prime decomposition task
|
||||
|
||||
let data = [112272537195293L; 112582718962171L; 112272537095293L; 115280098190773L; 115797840077099L; 1099726829285419L]
|
||||
let decomp num = decompose num 2L
|
||||
|
||||
let largestMinPrimeFactor (numbers: int64 list) =
|
||||
let decompDetails = Async.Parallel [ for n in numbers -> async { return n, decomp n } ] // Compute the number and its prime decomposition list
|
||||
|> Async.RunSynchronously // Start and wait for all parallel computations to complete.
|
||||
|> Array.sortBy (snd >> List.min >> (~-)) // Sort in descending order, based on the min prime decomp number.
|
||||
|
||||
decompDetails.[0]
|
||||
|
||||
let showLargestMinPrimeFactor numbers =
|
||||
let number, primeList = largestMinPrimeFactor numbers
|
||||
printf "Number %d has largest minimal factor:\n " number
|
||||
List.iter (printf "%d ") primeList
|
||||
|
||||
showLargestMinPrimeFactor data
|
||||
Loading…
Add table
Add a link
Reference in a new issue