错误FS0001:类型不匹配。期待' a - > int但给出了&a;>单元

时间:2014-07-26 01:30:27

标签: f#

收到错误:

"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

1 个答案:

答案 0 :(得分:5)

请参阅[<EntryPoint>]上的MSDN文档 - 您需要从主要功能返回int