skvsree
skvsree

Reputation: 497

error FS0001: Type mismatch. Expecting a 'a -> int but given a 'a -> unit

Receiving an error:

"error FS0001: Type mismatch. Expecting a 'a -> int but given a 'a -> unit"

I am using Sublime text for the following code:

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

Upvotes: 0

Views: 2270

Answers (1)

kvb
kvb

Reputation: 55184

See the MSDN docs on [<EntryPoint>] - you need to return an int from your main function.

Upvotes: 5

Related Questions