收到错误:
"error FS0001: Type mismatch. Expecting a 'a -> int but given a 'a -> unit"
我使用Sublime文本代码如下:
namespace eulers
module problems =
open System.Numerics
[<EntryPoint>]
let main args =
let isPrime n = [2L..int64 (sqrt (float n))] |> Seq.exists(fun x -> n % x = 0L) |> not
let p1 = [1..999] |> Seq.filter(fun x -> x % 3 = 0 || x % 5 = 0) |> Seq.sum
let p2 = Seq.unfold(fun(x,y) -> Some(x, (y, x + y))) (0L, 1L) |> Seq.takeWhile(fun x -> x < 4000000L) |> Seq.filter(fun x -> x % 2L = 0L) |> Seq.sum
let p3 = [2L.. int64 (sqrt (float 600851475143L))] |> Seq.filter(fun x -> 600851475143L % x = 0L && isPrime x) |> Seq.max
printf "%d" p1