Cloud Training (Online)




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

Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.