As per I have understood your requirement, you want to divide two values (for e.g. 5 by 2)
, and then want to roundoff them to nearest integer number.
For same code below in F#:
// Function for dividing
let divide x y =
x / y
// _ is main function in F#
let _ =
let result = divide 5M 2M
let roundOff = ceil result
Understanding the code:
(1) open System is equivalent to using System in C#
(2) Declared function named divide that accepts two arguments x and y, and then return result of type decimal. This is calculated automatically by F# compiler.
(3) Third we have called the divide function in main function _
, rounded off the result by using ceil
method of Math class. And at last showed the result to user by Console.WriteLine.
Select the entire code in VS IDE and then right click --> select Send to Interactive (Alt + Enter)
Hope this helps.