Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- let rec sumupto n = if n=0 then 0 else n + sumupto (n-1)
- let rec factorial n = if n=0 then 1 else n * factorial (n-1)
- let div n : float = float (sumupto n)/float (factorial n)
- let read() =
- printfn "Please enter a number."
- System.Console.ReadLine()
- let convert (source : string) =
- try System.Int32.Parse(source)
- with :? System.FormatException ->
- printfn "'%s' is not a number!" source;
- exit 1
- let num1 : int = read() |> convert
- printfn "result=%f" ( div num1 )
- Console.ReadLine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement