Home.NETF# Recipe #1 – Display Odd Numbers between 0 and 100 in Console Window

F# Recipe #1 – Display Odd Numbers between 0 and 100 in Console Window

Problem

You need to write a F# program to display odd numbers between 0 and 100 in the console window.

F# Program to display odd numbers between 0 and 100 in the Console Window.

open System
[<EntryPoint>]
let main argv = 
    let mutable sum = 0
    for index=0 to 100 do
        if index%2 <> 0 then 
            sum <- sum + index
    printfn "sum is %A" sum
    let ret = Console.ReadLine()
    0//

Output

sum is 2500

Share:

Leave a Reply

You May Also Like

In this post, you’ll learn about the error message “WorkbookNotSupported – The file you selected cannot be opened because it...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SpecifiedRangeNotFound – The requested range does not exist in the sheet.”...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SheetRangeMismatch – The sheet provided as the sheet argument is not...
  • .NET
  • December 17, 2022