Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.82 KB | None | 0 0
  1. // Learn more about F# at http://fsharp.org
  2.  
  3. open System
  4. open System.Diagnostics
  5. open System.Threading
  6.  
  7. let isPrimeNumber x =  
  8.         let mutable i = 2  
  9.         let mutable isFactorFound= false  
  10.         while not isFactorFound&& i < x do  
  11.             if x % i = 0 then  
  12.                 isFactorFound<-true  
  13.             i <- i + 1  
  14.         not isFactorFound
  15.  
  16. let sw = new System.Diagnostics.Stopwatch()
  17. let ResetStopWatch ()=
  18.     sw.Reset ()
  19.     sw.Start ()
  20.  
  21. let ShowTime ()=
  22.     printfn "took me %d ms" sw.ElapsedMilliseconds
  23.  
  24. let executeTest1 () =
  25.     let intArray = [| for i in 10000000..10004000 -> i |]
  26.     ResetStopWatch ()
  27.     let primeDetails1 = intArray |> Array.map (fun x -> (x, isPrimeNumber x))
  28.     ShowTime()
  29.  
  30.  
  31.  
  32. [<EntryPoint>]
  33. let main argv =
  34.     0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement