F Sharp Loops for...to and for...downto - F Sharp (programming language)

What is F# - for...to and for...downto?

A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.

Syntax

The syntax of a for…to loop in F# programming language is −

Example 1

The following program prints out the numbers 1 - 20 −

When you compile and execute the program, it yields the following output −

Example 2

The following program counts in reverse and prints out the numbers 20 - 1 −

When you compile and execute the program, it yields the following output −

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

F Sharp (programming language) Topics