let IsNotMultipleOf n x =
x=n || x%n<>0
let rec RemoveAllMultiples listn listx =
match listn with
| head::tail -> RemoveAllMultiples tail (List.filter (IsNotMultipleOf head) listx)
| [] -> listx
let GetPrimeTo n =
let r= (int) ( sqrt(float n))
RemoveAllMultiples [2..r] [1..100]
printfn "%A" (GetPrimeTo 100)
Saturday, June 11, 2011
F# Finding Prime Number
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment