Recently , I started learning F# as hobby and started writing some simple programs . Today , I was trying out a sample program in F# which finds out the sum of odd numbers from 0 to 100 in F#.
How to Find the Sum of odd numbers from 0 to 100 in F# ?
Below is a sample code snippet that does the work.
// Ginktage - F# Program to find the sum of odd numbers from 0 to 100
let main argv =
let mutable sum = 0
for indexer=0 to 100 do
if indexer%2 <> 0 then
sum <- sum + indexer
printfn "Sum is %A" sum
// Printing the entered input
let retval = Console.ReadLine()
0 // return an integer exit code
You may also like -
- Declaring Variables in F#
- F# Compiler Error – This is not a valid numeric literal. Sample formats include 4, 0x4, 0b0100, 4L, 4UL, 4u, 4s, 4us, 4y, 4uy, 4.0, 4.0f, 4I
- How to force quit a program in Mac OS X ?
- C# Program to swap two numbers without using temporary variable
- How to Get the Host Name of the Current URL in ASP.NET MVC ?
- How to export Excel sheet to PDF format in Excel 2013 ?
- Grayscale & Pure Black and White View in Microsoft PowerPoint 2013
- How to Convert a string to a stream in C# ?
- Print a text N number of times in SQL Management Studio
- How to Pin a file to the Recent Presentations Menu list in Microsoft PowerPoint 2013 ?
- How to Shut down your Windows 10 PC (Technical Preview) ?
- Example of Spin Control in Microsoft Excel 2013
- Dialog Box launcher in Microsoft Excel 2013
- How to Pin an item permanently in PowerPoint 2013 ?
- How to find the Computer Name from Command line in Windows 10 ?